IT/Software/Docker: Difference between revisions
Walttheboss (talk | contribs) No edit summary |
Walttheboss (talk | contribs) No edit summary |
||
Line 2: | Line 2: | ||
If you always want to automatically get the latest version of Docker on Ubuntu, you must add its official repository to Ubuntu system. To do that, run the commands below to install prerequisite packages: | If you always want to automatically get the latest version of Docker on Ubuntu, you must add its official repository to Ubuntu system. To do that, run the commands below to install prerequisite packages: | ||
sudo apt update | <code>sudo apt update</code> | ||
sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common | |||
<code>sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common</code> | |||
Next, run the commands below to download and install Docker’s official GPG key. The key is used to validate packages installed from Docker’s repository making sure they’re trusted. | Next, run the commands below to download and install Docker’s official GPG key. The key is used to validate packages installed from Docker’s repository making sure they’re trusted. | ||
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - | <code>curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -</code> | ||
sudo apt-key fingerprint 0EBFCD88 | <code>sudo apt-key fingerprint 0EBFCD88</code> | ||
Now that the official GPG key is installed, run the commands below to add its stable repository to Ubuntu. To add the nightly or test repository, add the word nightly or test (or both) after the word stable in the commands below. | Now that the official GPG key is installed, run the commands below to add its stable repository to Ubuntu. To add the nightly or test repository, add the word nightly or test (or both) after the word stable in the commands below. | ||
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | <code>sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"</code> | ||
After this command, Docker’s official GPG and repository should be installed on Ubuntu. | After this command, Docker’s official GPG and repository should be installed on Ubuntu. | ||
If you have older versions of Docker, run the commands below to remove them: | If you have older versions of Docker, run the commands below to remove them: | ||
sudo apt-get remove docker docker-engine docker.io containerd runc | <code>sudo apt-get remove docker docker-engine docker.io containerd runc</code> | ||
When you have removed all the previous versions of Docker, run the commands below to install the latest and current stable version of Docker: | When you have removed all the previous versions of Docker, run the commands below to install the latest and current stable version of Docker: | ||
sudo apt-get install docker-ce docker-ce-cli containerd.io | <code>sudo apt-get install docker-ce docker-ce-cli containerd.io</code> | ||
This will install Docker software on Ubuntu. | This will install Docker software on Ubuntu. | ||
Add your account, for most cases it will be ubuntu, to Docker group and restart: | Add your account, for most cases it will be ubuntu, to Docker group and restart: | ||
sudo usermod -aG docker $USER | <code>sudo usermod -aG docker $USER</code> | ||
Reboot your instance: | Reboot your instance: | ||
sudo reboot | <code>sudo reboot</code> | ||
To verify that Docker CE is installed correctly you can run the hello-world image: | To verify that Docker CE is installed correctly you can run the hello-world image: | ||
sudo docker run hello-world | <code>sudo docker run hello-world</code> | ||
If Docker is installed correctly you will see the following response: | If Docker is installed correctly you will see the following response: | ||
Line 37: | Line 38: | ||
Then you need to install docker-compose. This makes it easier for you to install containers on docker. | Then you need to install docker-compose. This makes it easier for you to install containers on docker. | ||
To install it, run the commands below to download version 1.26.0. As of this writing, this was the current version. | To install it, run the commands below to download version 1.26.0. As of this writing, this was the current version. | ||
sudo curl -L "https://github.com/docker/compose/releases/download/1.26.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose | <code>sudo curl -L "https://github.com/docker/compose/releases/download/1.26.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose</code> | ||
After downloading it, run the commands below to apply executable permissions to the binary file and create a symbolic link to /usr/binary | After downloading it, run the commands below to apply executable permissions to the binary file and create a symbolic link to /usr/binary | ||
sudo chmod +x /usr/local/bin/docker-compose | <code>sudo chmod +x /usr/local/bin/docker-compose</code> | ||
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose | <code>sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose</code> | ||
Now, Docker Compose should work. To test it, we will run the command below: | Now, Docker Compose should work. To test it, we will run the command below: | ||
docker-compose --version | <code>docker-compose --version</code> | ||
You should see similar output as below: | You should see similar output as below: |
Revision as of 14:50, 19 August 2022
Install docker and docker-compose:
If you always want to automatically get the latest version of Docker on Ubuntu, you must add its official repository to Ubuntu system. To do that, run the commands below to install prerequisite packages:
sudo apt update
sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
Next, run the commands below to download and install Docker’s official GPG key. The key is used to validate packages installed from Docker’s repository making sure they’re trusted.
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88
Now that the official GPG key is installed, run the commands below to add its stable repository to Ubuntu. To add the nightly or test repository, add the word nightly or test (or both) after the word stable in the commands below.
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
After this command, Docker’s official GPG and repository should be installed on Ubuntu.
If you have older versions of Docker, run the commands below to remove them:
sudo apt-get remove docker docker-engine docker.io containerd runc
When you have removed all the previous versions of Docker, run the commands below to install the latest and current stable version of Docker:
sudo apt-get install docker-ce docker-ce-cli containerd.io
This will install Docker software on Ubuntu.
Add your account, for most cases it will be ubuntu, to Docker group and restart:
sudo usermod -aG docker $USER
Reboot your instance:
sudo reboot
To verify that Docker CE is installed correctly you can run the hello-world image:
sudo docker run hello-world
If Docker is installed correctly you will see the following response: Response: Hello from Docker! This message shows that your installation appears to be working correctly.
Then you need to install docker-compose. This makes it easier for you to install containers on docker.
To install it, run the commands below to download version 1.26.0. As of this writing, this was the current version.
sudo curl -L "https://github.com/docker/compose/releases/download/1.26.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
After downloading it, run the commands below to apply executable permissions to the binary file and create a symbolic link to /usr/binary
sudo chmod +x /usr/local/bin/docker-compose
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
Now, Docker Compose should work. To test it, we will run the command below:
docker-compose --version
You should see similar output as below: Response: docker-compose version 1.24.0, build 0aa59064
Source: https://docs.fuga.cloud/how-to-install-portainer-docker-ui-manager-on-ubuntu-20.04-18.04-16.04