Initially, Docker was used as a Linux containerization tool. Support for other environments such as Windows and MacOS was added later. In this post, let us take a look at how to install Docker in the Linux platform and how to create the Docker images.
Installation of Docker at Linux (Ubuntu or similar) machine
Installation of Docker at Linux is usually pretty straightforward.
1) Open the Linux terminal
2) Run the command “sudo apt-get -y install docker.io”
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
falcon@falcon-Satellite-L50D-B:~$ sudo apt-get -y install docker.io Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: fonts-sil-gentium fonts-sil-gentium-basic fonts-stix libabw-0.1-1v5 libcdr-0.1-1 libcmis-0.5-5v5 libe-book-0.1-1 libeot0 libetonyek-0.1-1 libfreehand-0.1-1 libglew1.13 libhsqldb1.8.0-java libmspub-0.1-1 libmwaw-0.3-3 libodfgen-0.1-1 liborcus-0.10-0v5 libpagemaker-0.0-0 libreoffice-sdbc-firebird librevenge-0.0-0 libservlet3.1-java libvisio-0.1-1 libwpd-0.10-10 libwpg-0.3-3 libwps-0.4-4 linux-headers-4.4.0-62 linux-headers-4.4.0-62-generic linux-image-4.4.0-62-generic linux-image-extra-4.4.0-62-generic linux-signed-image-4.4.0-62-generic lp-solve Use 'sudo apt autoremove' to remove them. The following additional packages will be installed: cgroupfs-mount containerd runc ubuntu-fan ... ... Setting up docker.io (1.12.6-0ubuntu1~16.04.1) ... Adding group `docker' (GID 131) ... Done. Setting up ubuntu-fan (0.9.2) ... Processing triggers for systemd (229-4ubuntu16) ... Processing triggers for ureadahead (0.100.0-19) ... falcon@falcon-Satellite-L50D-B:~$ |
3) To verify the installation, use “sudo docker run hello-world”
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
falcon@falcon-Satellite-L50D-B:~$ sudo docker run hello-world Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world 78445dd45222: Pull complete Digest: sha256:c5515758d4c5e1e838e9cd307f6c6a0d620b5e07e6f927b07d05f6d12a1ac8d7 Status: Downloaded newer image for hello-world:latest Hello from Docker! This message shows that your installation appears to be working correctly. To generate this message, Docker took the following steps: 1. The Docker client contacted the Docker daemon. 2. The Docker daemon pulled the "hello-world" image from the Docker Hub. 3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading. 4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal. To try something more ambitious, you can run an Ubuntu container with: $ docker run -it ubuntu bash Share images, automate workflows, and more with a free Docker ID: https://cloud.docker.com/ For more examples and ideas, visit: https://docs.docker.com/engine/userguide/ falcon@falcon-Satellite-L50D-B:~$ |
4) To get more details about how to use the docker command use “docker –help”
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
~$ docker --help Usage: docker [OPTIONS] COMMAND [arg...] docker [ --help | -v | --version ] A self-sufficient runtime for containers. Options: --config=~/.docker Location of client config files -D, --debug Enable debug mode -H, --host=[] Daemon socket(s) to connect to -h, --help Print usage -l, --log-level=info Set the logging level --tls Use TLS; implied by --tlsverify --tlscacert=~/.docker/ca.pem Trust certs signed only by this CA --tlscert=~/.docker/cert.pem Path to TLS certificate file --tlskey=~/.docker/key.pem Path to TLS key file --tlsverify Use TLS and verify the remote -v, --version Print version information and quit Commands: attach Attach 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 ... ... |
To get the help screen about a specific Docker command, use “docker <command> –help”
Example :
1 2 3 4 5 6 7 8 9 |
~$ docker build --help Usage: docker build [OPTIONS] PATH | URL | - Build an image from a Dockerfile Options: --build-arg value Set build-time variables (default []) --cgroup-parent string Optional parent cgroup for the container |
To get the version information use “docker version” command.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
~/temp$ sudo docker version Client: Version: 1.12.6 API version: 1.24 Go version: go1.6.2 Git commit: 78d1802 Built: Tue Jan 31 23:35:14 2017 OS/Arch: linux/amd64 Server: Version: 1.12.6 API version: 1.24 Go version: go1.6.2 Git commit: 78d1802 Built: Tue Jan 31 23:35:14 2017 OS/Arch: linux/amd64 |