Dear Readers,
In this article, we will see Install Docker in Amazon Linux Machine.
What is Docker?
To know about more on Docker please check below link.
Steps to Follow
- Launch Docker Machine.
- Connect to Docker Linux EC2 Terminal through Putty.
- Switch to root user.
- Update Server Packages.
- Install Docker Package.
- Start the service of Docker.
- Verify the status of Docker.
- See the list of all images inside your machine.
- See the list of all running containers.
- See the list of all containers inside your machine.
1. Launch Docker Machine
we need to open SSH and HTTP ports.
Please check below link to Launch Linux EC2 Instance.
We can see Docker “Docker” which was created earlier.
2. Connect to Docker Linux EC2 Terminal through Putty
Open Docker Linux EC2 Instance Terminal
1 2 3 4 5 6 7 8 9 10 11 |
Using username "ec2-user". Authenticating with public key "imported-openssh-key" __| __|_ ) _| ( / Amazon Linux 2 AMI ___|\___|___| https://aws.amazon.com/amazon-linux-2/ 5 package(s) needed for security, out of 13 available Run "sudo yum update" to apply all updates. [ec2-user@ip-172-31-4-99 ~]$ |
3. Switch to root user
1 2 |
[ec2-user@ip-172-31-4-99 ~]$ sudo su [root@ip-172-31-4-99 ec2-user]# |
4. Update Server Packages
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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
[root@ip-172-31-4-99 ec2-user]# yum update -y Loaded plugins: extras_suggestions, langpacks, priorities, update-motd amzn2-core | 2.4 kB 00:00:00 Resolving Dependencies --> Running transaction check ---> Package file.x86_64 0:5.11-33.amzn2.0.2 will be updated ---> Package file.x86_64 0:5.11-35.amzn2.0.1 will be an update ---> Package file-libs.x86_64 0:5.11-33.amzn2.0.2 will be updated ---> Package file-libs.x86_64 0:5.11-35.amzn2.0.1 will be an update ---> Package kernel.x86_64 0:4.14.154-128.181.amzn2 will be installed ---> Package python.x86_64 0:2.7.16-3.amzn2.0.1 will be updated ---> Package yum.noarch 0:3.4.3-158.amzn2.0.3 will be an update --> Finished Dependency Resolution Dependencies Resolved ================================================================================================ Package Arch Version Repository Size ================================================================================================ Installing: kernel x86_64 4.14.154-128.181.amzn2 amzn2-core 20 M python2-rpm x86_64 4.11.3-40.amzn2.0.3 amzn2-core 84 k replacing rpm-python.x86_64 4.11.3-25.amzn2.0.3 Updating: file x86_64 5.11-35.amzn2.0.1 amzn2-core 57 k file-libs x86_64 5.11-35.amzn2.0.1 amzn2-core 339 k python x86_64 2.7.16-4.amzn2 amzn2-core 92 k yum noarch 3.4.3-158.amzn2.0.3 amzn2-core 1.2 M Cleanup : yum-3.4.3-158.amzn2.0.2.noarch 15/25 Erasing : rpm-python-4.11.3-25.amzn2.0.3.x86_64 16/25 Cleanup : python-libs-2.7.16-3.amzn2.0.1.x86_64 24/25 Cleanup : rsyslog-8.24.0-16.amzn2.6.1.x86_64 25/25 Verifying : python-libs-2.7.16-4.amzn2.x86_64 1/25 Verifying : file-5.11-35.amzn2.0.1.x86_64 2/25 Verifying : python-2.7.16-4.amzn2.x86_64 3/25 Verifying : yum-3.4.3-158.amzn2.0.3.noarch 4/25 Verifying : rpm-libs-4.11.3-40.amzn2.0.3.x86_64 5/25 Verifying : rpm-build-libs-4.11.3-40.amzn2.0.3.x86_64 6/25 Verifying : kernel-4.14.154-128.181.amzn2.x86_64 7/25 Verifying : rpm-4.11.3-40.amzn2.0.3.x86_64 8/25 Verifying : file-libs-5.11-35.amzn2.0.1.x86_64 9/25 Verifying : rsyslog-8.24.0-41.amzn2.2.1.x86_64 10/25 Verifying : rpm-plugin-systemd-inhibit-4.11.3-40.amzn2.0.3.x86_64 11/25 Verifying : python-devel-2.7.16-4.amzn2.x86_64 12/25 Verifying : python2-rpm-4.11.3-40.amzn2.0.3.x86_64 13/25 Verifying : python-devel-2.7.16-3.amzn2.0.1.x86_64 14/25 Verifying : rpm-python-4.11.3-25.amzn2.0.3.x86_64 21/25 Verifying : rpm-plugin-systemd-inhibit-4.11.3-25.amzn2.0.3.x86_64 22/25 Verifying : yum-3.4.3-158.amzn2.0.2.noarch 23/25 Verifying : rsyslog-8.24.0-16.amzn2.6.1.x86_64 24/25 Verifying : file-libs-5.11-33.amzn2.0.2.x86_64 25/25 Installed: kernel.x86_64 0:4.14.154-128.181.amzn2 python2-rpm.x86_64 0:4.11.3-40.amzn2.0.3 Updated: file.x86_64 0:5.11-35.amzn2.0.1 file-libs.x86_64 0:5.11-35.amzn2.0.1 python.x86_64 0:2.7.16-4.amzn2 python-devel.x86_64 0:2.7.16-4.amzn2 python-libs.x86_64 0:2.7.16-4.amzn2 rpm.x86_64 0:4.11.3-40.amzn2.0.3 rpm-build-libs.x86_64 0:4.11.3-40.amzn2.0.3 rpm-libs.x86_64 0:4.11.3-40.amzn2.0.3 rpm-plugin-systemd-inhibit.x86_64 0:4.11.3-40.amzn2.0.3 rsyslog.x86_64 0:8.24.0-41.amzn2.2.1 yum.noarch 0:3.4.3-158.amzn2.0.3 Replaced: rpm-python.x86_64 0:4.11.3-25.amzn2.0.3 Complete! |
5. Install Docker Package
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 29 30 31 32 33 34 |
[root@ip-172-31-4-99 ec2-user]# yum install docker -y Loaded plugins: extras_suggestions, langpacks, priorities, update-motd Resolving Dependencies --> Running transaction check ---> Package docker.x86_64 0:18.09.9ce-2.amzn2 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: docker x86_64 18.09.9ce-2.amzn2 amzn2extra-docker 30 M Transaction Summary ================================================================================ Install 1 Package Total download size: 30 M Installed size: 127 M Downloading packages: docker-18.09.9ce-2.amzn2.x86_64.rpm | 30 MB 00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : docker-18.09.9ce-2.amzn2.x86_64 1/1 Verifying : docker-18.09.9ce-2.amzn2.x86_64 1/1 Installed: docker.x86_64 0:18.09.9ce-2.amzn2 Complete! |
Verify the docker installed or not
1 2 |
[root@ip-172-31-4-99 ec2-user]# which docker /bin/docker |
Verify Version of Docker
1 2 3 4 5 |
[root@ip-172-31-4-99 ec2-user]# docker --version Docker version 18.09.9-ce, build 039a7df [root@ip-172-31-4-99 ec2-user]# docker -v Docker version 18.09.9-ce, build 039a7df |
6. Start the service of Docker
1 2 |
[root@ip-172-31-4-99 ec2-user]# service docker start Redirecting to /bin/systemctl start docker.service |
7. Verify the status of Docker
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 |
[root@ip-172-31-4-99 ec2-user]# service docker status Redirecting to /bin/systemctl status docker.service ● docker.service - Docker Application Container Engine Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled) Active: active (running) since Tue 2020-01-07 13:28:41 UTC; 20h ago Docs: https://docs.docker.com Process: 18414 ExecStartPre=/usr/libexec/docker/docker-setup-runtimes.sh (code=exited, status=0/SUCCESS) Process: 18404 ExecStartPre=/bin/mkdir -p /run/docker (code=exited, status=0/SUCCESS) Main PID: 18424 (dockerd) Tasks: 11 Memory: 316.2M CGroup: /system.slice/docker.service └─18424 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock --d... Jan 08 06:00:32 ip-172-31-4-99.ap-south-1.compute.internal dockerd[18424]: time="2020-01-08T0... Jan 08 06:15:01 ip-172-31-4-99.ap-south-1.compute.internal dockerd[18424]: time="2020-01-08T0... Jan 08 06:15:02 ip-172-31-4-99.ap-south-1.compute.internal dockerd[18424]: time="2020-01-08T0... Jan 08 06:15:03 ip-172-31-4-99.ap-south-1.compute.internal dockerd[18424]: time="2020-01-08T0... Jan 08 06:15:03 ip-172-31-4-99.ap-south-1.compute.internal dockerd[18424]: time="2020-01-08T0... Jan 08 06:17:30 ip-172-31-4-99.ap-south-1.compute.internal dockerd[18424]: time="2020-01-08T0... Jan 08 08:49:58 ip-172-31-4-99.ap-south-1.compute.internal dockerd[18424]: time="2020-01-08T0... Jan 08 08:49:59 ip-172-31-4-99.ap-south-1.compute.internal dockerd[18424]: time="2020-01-08T0... Jan 08 08:50:00 ip-172-31-4-99.ap-south-1.compute.internal dockerd[18424]: time="2020-01-08T0... Jan 08 08:50:00 ip-172-31-4-99.ap-south-1.compute.internal dockerd[18424]: time="2020-01-08T0... Hint: Some lines were ellipsized, use -l to show in full. |
We can use command “docker info” to get complete information about docker.
Verify the status of Docker (Running or not)
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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
[root@ip-172-31-4-99 ec2-user]# docker info Containers: 3 Running: 0 Paused: 0 Stopped: 3 Images: 8 Server Version: 18.09.9-ce Storage Driver: overlay2 Backing Filesystem: xfs Supports d_type: true Native Overlay Diff: true Logging Driver: json-file Cgroup Driver: cgroupfs Plugins: Volume: local Network: bridge host macvlan null overlay Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog Swarm: inactive Runtimes: runc Default Runtime: runc Init Binary: docker-init containerd version: 894b81a4b802e4eb2a91d1ce216b8817763c29fb runc version: 2b18fe1d885ee5083ef9f0838fee39b62d653e30 init version: fec3683 Security Options: seccomp Profile: default Kernel Version: 4.14.152-127.182.amzn2.x86_64 Operating System: Amazon Linux 2 OSType: linux Architecture: x86_64 CPUs: 1 Total Memory: 983.7MiB Name: ip-172-31-4-99.ap-south-1.compute.internal ID: Z2NK:6XYB:REK6:MZMH:XKA7:FKJZ:2Z66:UUTN:IA33:KPQC:3EFF:3NVG Docker Root Dir: /var/lib/docker Debug Mode (client): false Debug Mode (server): false Registry: https://index.docker.io/v1/ Labels: Experimental: false Insecure Registries: 127.0.0.0/8 Live Restore Enabled: false |
8. To see the list of all images inside your machine
1 2 |
[root@ip-172-31-4-99 ec2-user]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE |
9. To see the list of all running containers
1 2 |
[root@ip-172-31-4-99 ec2-user]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES |
10. To see the list of all containers inside your machine
1 2 |
[root@ip-172-31-4-99 ec2-user]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES |
Thank you for giving your valuable time to read the above information. Please click here to subscribe for further updates
KTEXPERTS is always active on below social media platforms.
Facebook : https://www.facebook.com/ktexperts/
LinkedIn : https://www.linkedin.com/company/ktexperts/
Twitter : https://twitter.com/ktexpertsadmin
YouTube : https://www.youtube.com/c/ktexperts
Instagram : https://www.instagram.com/knowledgesharingplatform