Estimated reading time: 7 minutes
Instructions for installing Docker Engine on Debian. Got multiple Docker repositories? If you have multiple Docker repositories enabled, installing or updating without specifying a version in the apt-get install or apt-get update command always installs the highest possible version, which may not be appropriate for your stability needs. $ sudo apt-get install docker-ce= docker-ce-cli= containerd.io Alternative Installation of Docker in Linux Previously we have seen how to install Docker in Linux from the repository with terminal line command. Details for docker License Apache-2.0 AND GPL-2.0 AND MIT Last updated 12 February 2021 Share this snap. Generate an embeddable card to be shared on external websites. On Linux systems, first install the Docker Engine for your OS as described on the Get Docker page, then come back here for instructions on installing Compose on Linux systems. To run Compose as a non-root user, see Manage Docker as a non-root user. In order to follow this article, you must have Docker installed on your computer. LinuxHint has a lot of articles that you can follow to install Docker on your desired Linux distribution if you don’t have it installed already. So, be sure to check LinuxHint.com in case you’re having trouble installing Docker. Installing Docker Compose.
You can run Compose on macOS, Windows, and 64-bit Linux.
Prerequisites
Docker Compose relies on Docker Engine for any meaningful work, so make sure youhave Docker Engine installed either locally or remote, depending on your setup.
On desktop systems like Docker Desktop for Mac and Windows, Docker Compose isincluded as part of those desktop installs.
On Linux systems, first install theDocker Enginefor your OS as described on the Get Docker page, then come back here forinstructions on installing Compose onLinux systems.
To run Compose as a non-root user, see Manage Docker as a non-root user.
Install Compose
Follow the instructions below to install Compose on Mac, Windows, Windows Server2016, or Linux systems, or find out about alternatives like using the pip
Python package manager or installing Compose as a container.
Install a different version
The instructions below outline installation of the current stable release(v1.28.6) of Compose. To install a different version ofCompose, replace the given release number with the one that you want. Composereleases are also listed and available for direct download on theCompose repository release page on GitHub.To install a pre-release of Compose, refer to the install pre-release buildssection.
Install Compose on macOS
Docker Desktop for Mac includes Compose alongwith other Docker apps, so Mac users do not need to install Compose separately.For installation instructions, see Install Docker Desktop on Mac.
Install Compose on Windows desktop systems
Docker Desktop for Windows includes Composealong with other Docker apps, so most Windows users do not need toinstall Compose separately. For install instructions, see Install Docker Desktop on Windows.
If you are running the Docker daemon and client directly on MicrosoftWindows Server, follow the instructions in the Windows Server tab.
Install Compose on Windows Server
Follow these instructions if you are running the Docker daemon and client directlyon Microsoft Windows Server and want to install Docker Compose.
Start an “elevated” PowerShell (run it as administrator).Search for PowerShell, right-click, and chooseRun as administrator. When asked if you want to allow this appto make changes to your device, click Yes.
In PowerShell, since GitHub now requires TLS1.2, run the following:
Then run the following command to download the current stable release ofCompose (v1.28.6):
Note: On Windows Server 2019, you can add the Compose executable to $Env:ProgramFilesDocker
. Because this directory is registered in the system PATH
, you can run the docker-compose --version
command on the subsequent step with no additional configuration.
Test the installation.
Install Compose on Linux systems
On Linux, you can download the Docker Compose binary from theCompose repository release page on GitHub.Follow the instructions from the link, which involve running the curl
commandin your terminal to download the binaries. These step-by-step instructions arealso included below.
For alpine
, the following dependency packages are needed:py-pip
, python3-dev
, libffi-dev
, openssl-dev
, gcc
, libc-dev
, rust
, cargo
and make
.
Run this command to download the current stable release of Docker Compose:
To install a different version of Compose, substitute
1.28.6
with the version of Compose you want to use.If you have problems installing with
curl
, seeAlternative Install Options tab above.Apply executable permissions to the binary:
Note: If the command docker-compose
fails after installation, check your path.You can also create a symbolic link to /usr/bin
or any other directory in your path.
For example:
Optionally, install command completion for the
bash
andzsh
shell.Test the installation.
Alternative install options
Install using pip
For alpine
, the following dependency packages are needed:py-pip
, python3-dev
, libffi-dev
, openssl-dev
, gcc
, libc-dev
, rust
, cargo
, and make
.
Compose can be installed frompypi using pip
. If you installusing pip
, we recommend that you use avirtualenv because many operatingsystems have python system packages that conflict with docker-composedependencies. See the virtualenvtutorial to getstarted.
If you are not using virtualenv,
pip version 6.0 or greater is required.
Install as a container
Compose can also be run inside a container, from a small bash script wrapper. Toinstall compose as a container run this command:
Install pre-release builds
If you’re interested in trying out a pre-release build, you can download releasecandidates from the Compose repository release page on GitHub.Follow the instructions from the link, which involves running the curl
commandin your terminal to download the binaries.
Pre-releases built from the “master” branch are also available for download athttps://dl.bintray.com/docker-compose/master/.
Pre-release builds allow you to try out new features before they are released,but may be less stable.
Upgrading
If you’re upgrading from Compose 1.2 or earlier, remove ormigrate your existing containers after upgrading Compose. This is because, as ofversion 1.3, Compose uses Docker labels to keep track of containers, and yourcontainers need to be recreated to add the labels.
If Compose detects containers that were created without labels, it refusesto run, so that you don’t end up with two sets of them. If you want to keep usingyour existing containers (for example, because they have data volumes you wantto preserve), you can use Compose 1.5.x to migrate them with the followingcommand:
Alternatively, if you’re not worried about keeping them, you can remove them.Compose just creates new ones.
Uninstallation
To uninstall Docker Compose if you installed using curl
:
To uninstall Docker Compose if you installed using pip
:
Got a “Permission denied” error?
If you get a “Permission denied” error using either of the abovemethods, you probably do not have the proper permissions to removedocker-compose
. To force the removal, prepend sudo
to either of the abovecommands and run again.
Where to go next
compose, orchestration, install, installation, docker, documentation- Docker Tutorial
- Docker Useful Resources
- Selected Reading
To start the installation of Docker, we are going to use an Ubuntu instance. You can use Oracle Virtual Box to setup a virtual Linux instance, in case you don’t have it already.
The following screenshot shows a simple Ubuntu server which has been installed on Oracle Virtual Box. There is an OS user named demo which has been defined on the system having entire root access to the sever.
To install Docker, we need to follow the steps given below.
Step 1 − Before installing Docker, you first have to ensure that you have the right Linux kernel version running. Docker is only designed to run on Linux kernel version 3.8 and higher. We can do this by running the following command.
uname
This method returns the system information about the Linux system.
Syntax
Options
a − This is used to ensure that the system information is returned.
Return Value
This method returns the following information on the Linux system −
- kernel name
- node name
- kernel release
- kernel version
- machine
- processor
- hardware platform
- operating system
Example
Output
When we run above command, we will get the following result −
From the output, we can see that the Linux kernel version is 4.2.0-27 which is higher than version 3.8, so we are good to go.
Step 2 − You need to update the OS with the latest packages, which can be done via the following command −
This method installs packages from the Internet on to the Linux system.
Syntax
sudo apt-get update
Options
sudo − The sudo command is used to ensure that the command runs with root access.
update − The update option is used ensure that all packages are updated on the Linux system.
Return Value
None
Example
Output
When we run the above command, we will get the following result −
This command will connect to the internet and download the latest system packages for Ubuntu.
Step 3 − The next step is to install the necessary certificates that will be required to work with the Docker site later on to download the necessary Docker packages. It can be done with the following command.
Step 4 − The next step is to add the new GPG key. This key is required to ensure that all data is encrypted when downloading the necessary packages for Docker.
The following command will download the key with the ID 58118E89F3A912897C070ADBF76221572C52609D from the keyserver hkp://ha.pool.sks-keyservers.net:80 and adds it to the adv keychain. Please note that this particular key is required to download the necessary Docker packages.
Step 5 − Next, depending on the version of Ubuntu you have, you will need to add the relevant site to the docker.list for the apt package manager, so that it will be able to detect the Docker packages from the Docker site and download them accordingly.
Precise 12.04 (LTS) ─ deb https://apt.dockerproject.org/repoubuntu-precise main
Trusty 14.04 (LTS) ─ deb https://apt.dockerproject.org/repo/ ubuntu-trusty main
Wily 15.10 ─ deb https://apt.dockerproject.org/repo ubuntu-wily main
Xenial 16.04 (LTS) - https://apt.dockerproject.org/repo ubuntu-xenial main
Since our OS is Ubuntu 14.04, we will use the Repository name as “deb https://apt.dockerproject.org/repoubuntu-trusty main”.
And then, we will need to add this repository to the docker.list as mentioned above.
Step 6 − Next, we issue the apt-get update command to update the packages on the Ubuntu system.
Step 7 − If you want to verify that the package manager is pointing to the right repository, you can do it by issuing the apt-cache command.
In the output, you will get the link to https://apt.dockerproject.org/repo/
Step 8 − Issue the apt-get update command to ensure all the packages on the local system are up to date.
Step 9 − For Ubuntu Trusty, Wily, and Xenial, we have to install the linux-image-extra-* kernel packages, which allows one to use the aufs storage driver. This driver is used by the newer versions of Docker.
It can be done by using the following command.
Step 10 − The final step is to install Docker and we can do this with the following command −
Here, apt-get uses the install option to download the Docker-engine image from the Docker website and get Docker installed.
The Docker-engine is the official package from the Docker Corporation for Ubuntu-based systems.
In the next section, we will see how to check for the version of Docker that was installed.
Docker Version
To see the version of Docker running, you can issue the following command −
Syntax
Options
version − It is used to ensure the Docker command returns the Docker version installed.
Return Value
The output will provide the various details of the Docker version installed on the system.
Example
Output
Docker Linux Sudo Command Not Found
When we run the above program, we will get the following result −
Docker Info
To see more information on the Docker running on the system, you can issue the following command −
Syntax
Options
info − It is used to ensure that the Docker command returns the detailed information on the Docker service installed.
Return Value
The output will provide the various details of the Docker installed on the system such as −
Docker Linux Sudo Usb
- Number of containers
- Number of images
- The storage driver used by Docker
- The root directory used by Docker
- The execution driver used by Docker
Example
Output
When we run the above command, we will get the following result −
Docker for Windows
Docker Alpine Linux Sudo
Docker has out-of-the-box support for Windows, but you need to have the following configuration in order to install Docker for Windows.
System Requirements
Windows OS | Windows 10 64 bit |
Memory | 2 GB RAM (recommended) |
You can download Docker for Windows from − https://docs.docker.com/docker-for-windows/
Docker ToolBox
Docker Linux No Sudo
Docker ToolBox has been designed for older versions of Windows, such as Windows 8.1 and Windows 7. You need to have the following configuration in order to install Docker for Windows.
Docker Linux Sudo Linux
System Requirements
Windows OS | Windows 7 , 8, 8.1 |
Memory | 2 GB RAM (recommended) |
Virtualization | This should be enabled. |
Linux Docker-compose Sudo
You can download Docker ToolBox from − https://www.docker.com/products/docker-toolbox