how to install docker on ubuntu?
Docker is an open-source platform that allows you to run applications in containers. These containers are lightweight and portable, which makes it easier to manage and deploy applications.
Below are the steps to be followed to
install Docker on Ubuntu:
Step 1: Update the package list Before installing Docker, it is recommended to update the package list of your Ubuntu system. You can do this by running the following command:
Step 2:
Install Docker: To install Docker on Ubuntu, you can use the official Docker
repository. Follow the steps below:
- Add the Docker GPG key to your system:
curl -fsSL
https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add –
- Add the Docker repository to APT sources:
sudo add-apt-repository
"deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release
-cs) stable"
- Update the package list again:
sudo apt-get update
- Finally, install Docker:
sudo apt-get install
docker-ce
Step 3:
Verify the installation After installing Docker, you can verify that it is
working correctly by running the following command:
sudo
docker run hello-world
This command
will download a small Docker image and run it in a container. If everything is
working correctly, you should see the following output:
Hello
from Docker!
This message
shows that your installation appears to be working correctly.
Step 4:
Manage Docker as a non-root user By default, Docker requires root privileges to
run. However, you can configure Docker to be managed by a non-root user. Follow
the steps below:
- Create a new group called docker:
sudo groupadd docker
- Add your user to the docker group:
sudo usermod -aG docker $USER
- Log out and log back in to apply the group membership
changes.
- Verify that you can run Docker commands without sudo:
docker run hello-world
Step 5: Use
Docker Compose (optional) Docker Compose is a tool that allows you to define
and run multi-container Docker applications. To install Docker Compose, follow
these steps:
- Download the latest version of Docker Compose:
sudo curl -L https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname
-s)-$(uname -m)" -o /usr/local/bin/docker-compose
- Apply executable permissions to the binary:
sudo chmod +x /usr/local/bin/docker-compose
- Verify that the installation was successful:
docker-compose –version
Conclusion In
this guide, we have the process on how to install Docker on Ubuntu. We also covered
how to manage Docker as a non-root user and how to install Docker Compose.
Comments
Post a Comment