There are no items in your cart
Add More
Add More
Item Details | Price |
---|
Sun Oct 29, 2023
Docker Engine is an open-source containerization technology for building and containerizing your applications.
Docker Engine acts as a client-server application with:
The CLI uses Docker APIs to control or interact with the Docker daemon through scripting or direct CLI commands. Many other Docker applications use the underlying API and CLI. The daemon creates and manages Docker objects, such as images, containers, networks, and volumes.
In this guide, we will walk you through the steps to install Docker on an Ubuntu 22.04 LTS-based AWS EC2 instance, enabling you to harness the benefits of containerization in the cloud.
Docker Engine is available on a variety of Linux distros, macOS, and Windows 10 through Docker Desktop, and as a static binary installation.
You can install Docker Engine in different ways, depending on your needs:
Before you begin, make sure you have the following prerequisites in place:
Use SSH to connect to your AWS EC2 instance
sudo apt update -y
# Add Docker's official GPG key:sudo apt-get updatesudo apt-get install ca-certificates curl gnupgsudo install -m 0755 -d /etc/apt/keyringscurl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpgsudo chmod a+r /etc/apt/keyrings/docker.gpg# Add the repository to Apt sources:echo \"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \sudo tee /etc/apt/sources.list.d/docker.list > /dev/nullsudo apt-get update
To install the latest version, run:
Running this command will install Docker and its associated components on your system, allowing you to work with Docker containers, build custom images, and manage multi-container applications using Docker Compose.sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Verify that the Docker Engine installation is successful by running the hello-world image.
sudo docker run hello-world
Congratulations, You have now successfully installed and started Docker Engine.
Note: If you try the above docker command without sudo, you will get an error permission denied.
docker run hello-world
We get this error because Docker requires administrative privileges to run, and the Ubuntu user does not have the necessary permissions.
You can resolve it by using sudo before Docker commands or adding the Ubuntu user to the docker group and applying the group membership changes.
The Docker daemon binds to a Unix socket, not a TCP port. By default, it's the root user that owns the Unix socket, and other users can only access it using sudo. The Docker daemon always runs as the root user.
If you don't want to preface the docker command with sudo, create a Unix group called docker and add users to it. When the Docker daemon starts, it creates a Unix socket accessible by members of the docker group. On some Linux distributions, the system automatically creates this group when installing Docker Engine using a package manager. In that case, there is no need for you to manually create the group.
In our case, the docker group is already created during the installation of the Docker Engine. You can check by executing the following command.
cat /etc/group | grep docker
Add non-root user to the docker group
sudo usermod -aG docker $USERwhen you run this command, it adds your current user to the "docker" group, allowing you to run Docker commands without having to use sudo each time.
Log out and log back in so that your group membership is re-evaluated or
Run the following command to activate the changes to groups
newgrp dockerVerify that you can run docker commands without sudo
docker run hello-world
To start the Docker and Containerd services automatically when your system boots up run the following commands
sudo systemctl enable docker.servicesudo systemctl enable containerd.service
In this tutorial, we've covered the steps to install Docker on an Ubuntu 22.04 LTS-based AWS EC2 instance successfully
I hope you enjoyed reading this blog and found it informative. If you have any questions or topics you'd like us to cover in future blogs, please don't hesitate to connect with me on LinkedIn. Thank you for joining us on this Docker journey,