Hello All,
I had recently learnt a bit of Docker(which provides containerization process).
Here are some of my learning points from it.
Let us start first with very basic question:
What is Docker:
Docker is a platform for sysadmins and developers to DEPLOY, DEVELOP and RUN applications with containers.
The use of Linux containers to deploy applications is called containerization.
Flexible: Even the most complex applications can be containerized.
Lightweight: Containers leverage and share the host kernel.
Interchangeable: You can deploy updates and upgrades on-the-fly.
Portable: You can build locally, deploy to the cloud, and run anywhere.
Scalable: You can increase and automatically distribute container replicas.
Stackable: You can stack services vertically and on-the-fly.
What is an Image: We could say Image as an executable which has all things needed to run an application EG--> code, libraries, environment variables, config files.
What is Container: Whenever we run an image then its executable form is called Container.
Prerequisites: Ubuntu/Linux server then in case you need to publish your images to Docker repository an account on Docker HUB.
Steps for installing Docker:
1st Step: Use curl
command to install its binaries along with apt-key
to make sure downloads are valid.
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
2nd Step: Add Docker repository to APT resources:
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
3rd Step: Update apt-get
for Ubuntu server(where we are going to learn Docker)
sudo apt-get update
4th Step: To make sure we are going to install Docker from Docker's repo rather than default Ubuntu 16.04 repo run following.
apt-cache policy docker-ce
5th Step: Finally Install Docker now.
sudo apt-get install -y docker-ce
6th Step: Run systemctl
to make sure that this service is added in rc boot of server and should come up after reboot of server.
sudo systemctl status docker
docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2018-10-18 20:28:23 UTC; 35s ago
Docs: https://docs.docker.com
Main PID: 13412 (dockerd)
CGroup: /system.slice/docker.service
13412 /usr/bin/dockerd -H fd://
13421 docker-containerd --config /var/run/docker/containerd/containerd.toml
7th Step: Now lets run only docker
command and see what output is coming.
attach Attach local standard input, output, and error streams to a running container
build Build an image from a Dockerfile
commit Create a new image from a container's changes
cp Copy files/folders between a container and the local filesystem
create Create a new container
diff Inspect changes to files or directories on a container's filesystem
events Get real time events from the server
exec Run a command in a running container
export Export a container's filesystem as a tar archive
history Show the history of an image
images List images
import Import the contents from a tarball to create a filesystem image
info Display system-wide information
inspect Return low-level information on Docker objects
kill Kill one or more running containers
load Load an image from a tar archive or STDIN
login Log in to a Docker registry
logout Log out from a Docker registry
logs Fetch the logs of a container
pause Pause all processes within one or more containers
port List port mappings or a specific mapping for the container
ps List containers
pull Pull an image or a repository from a registry
push Push an image or a repository to a registry
rename Rename a container
restart Restart one or more containers
rm Remove one or more containers
rmi Remove one or more images
run Run a command in a new container
save Save one or more images to a tar archive (streamed to STDOUT by default)
search Search the Docker Hub for images
start Start one or more stopped containers
stats Display a live stream of container(s) resource usage statistics
stop Stop one or more running containers
tag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
top Display the running processes of a container
unpause Unpause all processes within one or more containers
update Update configuration of one or more containers
version Show the Docker version information
wait Block until one or more containers stop, then print their exit codes
8th Step: Check for docker
version by running as follows.
docker --version
Docker version 18.09.0, build 4d60db4
9th Step: Pull first image from Docker's repository as follows.
docker run hello-world
Output approximate will be as follows.
...
Hello from Docker!
This message shows that your installation appears to be working correctly.
...
Will post further details on how to call a basic Python program through Docker image and show how it will NOT require packages(needed by that program) for your Ubuntu server(they will be their in containers to support programs not in local server).
One could refer Docker site's documentation in link Docker Documentation | Docker Documentation too.
Stay tuned with this thread. Your edits/views/comments/feed back are Welcome
Hello Neo,
Would like to request you if we can create a new forum for Docker, so users could post threads there.
Kindly do let me know your views on same.
Thanks,
R. Singh