docker:install_docker
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
docker:install_docker [2021/02/05 11:21] – peter | docker:install_docker [2025/06/07 16:56] (current) – peter | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Docker - Install Docker ====== | ====== Docker - Install Docker ====== | ||
- | ===== Check the kernel version and the OS architecture | + | ===== Prerequisites |
- | Run **uname -a** to check the version of the currently running Linux kernel: | + | <WRAP alert> |
+ | **ALERT:** | ||
- | <code bash> | + | * Docker is NOT compatible with **ufw**. |
- | uname -a | + | * See: https:// |
- | </code> | + | |
- | Check that it's a 64Bit Kernel (x86_64). | + | </ |
---- | ---- | ||
- | Check the Ubuntu version. | + | ===== Uninstall old versions ===== |
<code bash> | <code bash> | ||
- | cat /etc/lsb-release | + | for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt remove $pkg; done |
</ | </ | ||
- | The command shows that the Ubuntu version is 16.04. | + | <WRAP info> |
+ | **NOTE: | ||
- | ---- | + | * To start with a clean installation, |
- | It is recommended to update Ubuntu before you install new software. Run the following command to fetch the latest updates from the Ubuntu repository | + | </ |
+ | |||
+ | |||
+ | To delete all images, containers, | ||
<code bash> | <code bash> | ||
- | sudo apt update | + | sudo rm -rf / |
- | sudo upgrade | + | sudo rm -rf / |
</ | </ | ||
+ | |||
+ | Remove source list and keyrings | ||
+ | |||
+ | <code bash> | ||
+ | sudo rm / | ||
+ | sudo rm / | ||
+ | </ | ||
+ | |||
+ | <WRAP info> | ||
+ | **NOTE: | ||
+ | </ | ||
+ | |||
---- | ---- | ||
- | Now install docker with the apt command: | + | ===== Set up the Docker |
<code bash> | <code bash> | ||
- | sudo apt install -y docker.io | + | # Add Docker' |
+ | sudo apt update | ||
+ | sudo apt install | ||
+ | sudo install -m 0755 -d / | ||
+ | sudo curl -fsSL https:// | ||
+ | sudo chmod a+r / | ||
+ | |||
+ | # Add the repository to Apt sources: | ||
+ | echo \ | ||
+ | "deb [arch=$(dpkg --print-architecture) signed-by=/ | ||
+ | $(. / | ||
+ | sudo tee / | ||
+ | sudo apt update | ||
</ | </ | ||
- | |||
- | Wait until the installation has been completed. | ||
---- | ---- | ||
- | ===== Add your user to the docker group ===== | + | ===== Install |
<code bash> | <code bash> | ||
- | sudo usermod | + | sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin |
</ | </ | ||
<WRAP info> | <WRAP info> | ||
- | **NOTE: | + | **NOTE:** |
+ | |||
+ | * **docker-ce** - The Docker engine itself. | ||
+ | * **docker-ce-cli** - A command line tool that lets you talk to the Docker daemon. | ||
+ | * **containerd.io** - A container runtime that manages the container’s lifecycle. | ||
+ | * **docker-buildx-plugin** - This extension for Docker enhances the capabilities of building images, mainly focusing on multi-platform builds. | ||
+ | * **docker-compose-plugin** - A configuration management plugin that helps manage multi-container Docker applications | ||
</ | </ | ||
---- | ---- | ||
- | ===== Verify that you can run docker commands without sudo ===== | + | ===== Verify that the installation is successful |
<code bash> | <code bash> | ||
- | docker run hello-world | + | sudo docker run hello-world |
</ | </ | ||
- | <WRAP info> | + | returns: |
- | **NOTE:** If an error is seen such as **docker: Got permission denied while trying to connect to the Docker daemon socket**, then log out and log back in. | + | |
- | </ | + | |
+ | < | ||
+ | Unable to find image ' | ||
+ | latest: Pulling from library/ | ||
+ | e6590344b1a5: | ||
+ | Digest: sha256: | ||
+ | Status: Downloaded newer image for hello-world: | ||
- | ---- | + | Hello from Docker! |
+ | This message shows that your installation appears to be working correctly. | ||
- | Then you can start Docker | + | To generate this message, |
+ | 1. The Docker client contacted the Docker daemon. | ||
+ | 2. The Docker daemon pulled the " | ||
+ | (amd64) | ||
+ | 3. The Docker daemon created a new container from that image which runs the | ||
+ | executable that produces the output you are currently reading. | ||
+ | 4. The Docker daemon streamed that output to the Docker client, which sent it | ||
+ | to your terminal. | ||
- | < | + | To try something more ambitious, you can run an Ubuntu container with: |
- | systemctl start docker | + | $ docker run -it ubuntu |
+ | |||
+ | Share images, automate workflows, and more with a free Docker ID: | ||
+ | | ||
+ | |||
+ | For more examples and ideas, visit: | ||
+ | | ||
</ | </ | ||
- | ---- | + | <WRAP info> |
+ | **NOTE: | ||
- | Enable docker to run at system boot: | + | * When the container runs, it prints a confirmation message and exits. |
- | <code bash> | + | * If the command fails to run, try to restart the docker service, before rerunning this test: <code bash> |
- | systemctl | + | sudo systemctl |
</ | </ | ||
+ | |||
+ | </ | ||
---- | ---- | ||
- | You might also want to check the docker version: | + | ===== Uninstall Docker Engine ===== |
<code bash> | <code bash> | ||
- | docker | + | sudo apt purge docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-ce-rootless-extras |
</ | </ | ||
- | Show the currently installed Docker version. | + | Then, manually remove |
+ | |||
+ | <code bash> | ||
+ | sudo rm -rf / | ||
+ | sudo rm -rf / | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ===== References ===== | ||
+ | |||
+ | https:// | ||
- | Now docker | + | https:// |
- | You can start making a container by downloading a Docker Image from the Docker Registry. | + | https:// |
docker/install_docker.1612524077.txt.gz · Last modified: 2021/02/05 11:21 by peter