Install Latest Docker and Docker-compose on Ubuntu. # Ask for the user password. # Script only works if sudo caches the password for a few minutes. # Install kernel extra's to enable docker aufs support. # sudo apt-get -y install linux-image-extra-$ (uname -r). How to update packages inside a Docker container on Ubuntu If you want the package present in the current Docker container, then execute the “ apt update ” command in the following way: email protected:/# apt update. Dec 24, 2019 Install Docker on Ubuntu. For this article, we will use Ubuntu 18.04. Ubuntu 18.04; sudo user; Step 1: Update the local database. Before installation, start by updating the existing list for packages. Sudo apt update Step 2: Install dependencies that support https. Install packages that will allow apt to transfer files over https.
Build and run container images with Docker.
docker loadneed to be in $HOME.
Running Docker as normal user
By default, Docker is only accessible with root privileges (
sudo). If you want to use docker as a regular user, you need to add your user to the
Warning: if you add your user to the
docker group, it will have similar power as the
root user. For details on how this impacts security in your system, see https://docs.docker.com/engine/security/#docker-daemon-attack-surface
This snap is built by Canonical based on source code published by Docker, Inc. It is not endorsed or published by Docker, Inc.
Docker and the Docker logo are trademarks or registered trademarks of Docker, Inc. in the United States and/or other countries. Docker, Inc. and other parties may also have trademark rights in other terms used herein.
Docker is a free, open-source and cross-platform containerization tool that helps you to deploy and run the application in an isolated environment. Docker has become one of the most important parts of modern software development and DevOps pipelines.
In this tutorial, you will learn –
There are two ways to install Docker on Ubuntu 20.04. You can install Docker from the Ubuntu default repository or from the Docker’s official repository. The latest version of Docker is not included in the Ubuntu default repository. So it is always recommended to install Docker from Docker’s official repository.
In this section, we will show you how to install Docker on Ubuntu from Docker official repository.
First, you will need to install some prerequisite packages in your system. You can install them by running the following command:
Next, you will need to import the GPG key and add the Docker repository to your system.
First, import the GPG key with the following command:
Next, add the Docker official repository using the following command:
Once the repository is added, update the repository cache with the following command:
Once the repository is updated, you can install the Docker on Ubuntu by running the following command:
This command will install the latest version of Docker from the Docker official repository.
Once the Docker has been installed, you can verify the installed version of Docker with the following command:
You should get the following output:
If you want to install a specific Docker version, first list all available Docker versions using the following command:
You should see all the Docker version in the following output:
Now, install the specific version of Docker by adding =version after package name as shown below:
To start the Docker service, run the following command:
To enable the Docker service at system reboot, run the following command:
To check the status of Docker service, run the following command:
By default, Docker can be run as a root user or with Sudo privileges. If you want to run Docker commands as a non-root user then you will need to add your user to the docker group.
You can add your user to the docker group using the following command:
Now, your user can run Docker commands without specifying sudo.
You can list all commands available in Docker with the following command:
You should get a list of all commands in the following output:
To see system-wide information about Docker, run the following command:
At this point, Docker is installed and running in your system. Next, you will need to check whether you can access and download the image from DockerHub.
Let’s download the hello-world image from the DockerHub using the docker pull command:
This will download or pull the hello-world image from the DockerHub repository as shown below:
Next, verify the downloaded image with the following command :
You should see your downloaded image in the following output:
Next, run a container from the hello-world image with the following command:
You should see the following output:
If you want to uninstallDocker from your system. It is recommended to remove all Docker containers, images and volumes from your system.
First, stop all running containers with the following command:
Once all containers are stopped, remove them with the following command:
Next, remove all Docker images with the following command:
Next, remove all docker objects with the following command:
Finally, remove the Docker package with all dependencies by running the following command:
In the above post, you learned how to install and use Docker on Ubuntu 20.04. To learn more about Docker, check out my all Docker tutorial.