This post is to help in installing docker engine and docker-compose on almost any linux distro (with apt of course). So, without further ado, lets get cracking!
Deleting any existing installs
Run the command below:
|
|
Setting up your OS
Set up the repository
Run the commands to install prerequisites.
1 2 3 4 5 6 7 8
sudo apt-get update sudo apt-get install \ apt-transport-https \ ca-certificates \ curl \ gnupg-agent \ software-properties-common
Add docker’s official GPG key
1
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
Setup the stable docker repository
Note:
amd64
can be substituted forarmhf
orarm64
based on your system architecture. Seeuname -a
anduname -m
for more details.1 2 3 4
sudo add-apt-repository \ "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) \ stable"
Installing docker
Now, we can proceed to install docker by:
|
|
Optional: Add your user to the docker group so that you can use docker without su
|
|
Install docker-compose
Docker compose releases are provided in their github repo . You can install the 1.26.2 (latest as of writing this) as:
|
|
Verify the installation
Check the versions of docker-engine, docker-cli and docker-compose to see they have been installed successfully. See the docker website here and docker-compose here for more info.
|
|
Done, docker is ready
Now that you have docker and docker-compose installed, see a few samples below on how to use them:
|
|
Sample docker-compose to get you started :)
Try this docker-compose by saving the file below as docker-compose.yml
in an empty directory and run the commands. Substitute nano
for your favorite editor.
|
|
|
|
File docker-compose.yml
:
To see the deployed UI, hit the http://localhost:8081/
and see the Mongo Express UI connected to the Mongo DB container.
You can have a look at the full docker-compose syntax here .