-
Notifications
You must be signed in to change notification settings - Fork 0
01. Setting Up Docker on Ubuntu
Daniel Trolezi edited this page Nov 10, 2024
·
10 revisions
- Setup Docker's apt repository
# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
# Add the repository to Apt sources:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
- Install the Docker packages
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
- Verify that the Docker Engine installation is successful by running the hello-world image
sudo docker run hello-world
If you receive the error bellow:
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
See 'docker run --help'.
Create the docker group:
sudo groupadd docker
Add your user to the docker group:
sudo usermod -aG docker $USER
Reboot system so that your group membership is re-evaluated.
Ensure the group was added to you user:
groups
Ensure docker is running:
sudo systemctl status docker
If it doesn't, run:
sudo systemctl start docker
Try again, without sudo:
docker run hello-world
- List Networks
docker network list
- Create Network if there is no network with
DRIVER=bridge
andSCOPE=local
docker network create bridge
- Configure Docker to start on boot with systemd
sudo systemctl enable docker.service
sudo systemctl enable containerd.service
- Create new GPG Key
gpg --full-generate-key
- Get the GPG Key ID
gpg --list-secret-keys --keyid-format=long
It should return something like:
/Users/hubot/.gnupg/secring.gpg
------------------------------------
sec 4096R/3AA5C34371567BD2 2016-03-10 [expires: 2017-03-10]
uid Hubot <hubot@example.com>
ssb 4096R/4BB6D45482678BE3 2016-03-10
In that case, 3AA5C34371567BD2 is the ID.
- Set up Password Store
pass init 3AA5C34371567BD2
- Store temp password, necessary to proper initialize the service
pass insert docker-credential-helpers/tmp
- Check passwords
pass show
-
Download
docker-credential-pass
binary from docker-crential-helpers release page -
Rename it from
docker-credential-pass-v0.8.1.linux-amd64
todocker-credential-pass
$ cp ./docker-credential-pass-v0.8.1.linux-amd64 ./docker-credential-pass
$ rm docker-credential-pass-v0.8.1.linux-amd64
- Add binary to $PATH
$ cp ./docker-credential-pass /usr/local/bin/
$ rm docker-credential-pass
- Make it executable:
$ sudo chmod +x /usr/local/bin/docker-credential-pass
- Verify by running
docker-credential-pass
It should return something like this:
Usage: docker-credential-pass <store|get|erase|list|version>
- Download latest DEB package and install it
sudo apt-get update
sudo apt-get install ./docker-desktop-<version>-<arch>.deb
- Set
docker-credential-pass
as thecredsStore
for Docker. Open your~/.docker/config.json
file and change the value ofcredsStore
topass
:
{
"credsStore":"pass"
}
- Login into Docker Hub
docker login
- Verify
docker-credential-pass list
And also:
pass show
- Remove tmp password created on step 4:
pass remove docker-credential-helpers/tmp
- To start Docker Desktop for Linux, search Docker Desktop on the Applications menu and open it.