User Tools

Site Tools


docker:install_docker

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
docker:install_docker [2025/05/20 15:40] peterdocker: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:**  Docker is only compatible with **iptables** and **ip6tables**.
  
-<code bash> +  * Docker is NOT compatible with **ufw**. 
-uname -+  * See:  https://docs.docker.com/engine/network/packet-filtering-firewalls/
-</code>+
  
-Check that it's a 64Bit Kernel (x86_64).  Docker won't work without this.+</WRAP>
  
 ---- ----
  
-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
 </code> </code>
  
-The command shows that the Ubuntu version is 16.04.+<WRAP info> 
 +**NOTE:**  Images, containers, volumes, and networks stored in **/var/lib/docker/** are not automatically removed when you uninstall Docker.
  
-----+  * To start with a clean installation, to clean up any existing data, read the [[https://docs.docker.com/engine/install/ubuntu/#uninstall-docker-engine|uninstall Docker Engine section]].
  
-It is recommended to update Ubuntu before you install new software. Run the following command to fetch the latest updates from the Ubuntu repository and install them.+</WRAP> 
 + 
 + 
 +To delete all images, containers, and volumes:
  
 <code bash> <code bash>
-sudo apt update +sudo rm -rf /var/lib/docker 
-sudo upgrade+sudo rm -rf /var/lib/containerd
 </code> </code>
 +
 +Remove source list and keyrings
 +
 +<code bash>
 +sudo rm /etc/apt/sources.list.d/docker.list
 +sudo rm /etc/apt/keyrings/docker.asc
 +</code>
 +
 +<WRAP info>
 +**NOTE:**  Any edited configuration files will need to be deleted manually.
 +</WRAP>
 +
  
 ---- ----
  
-Now install docker with the apt command:+===== Set up the Docker apt repository =====
  
 <code bash> <code bash>
-sudo apt install -docker.io +# Add Docker's official GPG key: 
-</code>+sudo apt update 
 +sudo apt 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
  
-Wait until the installation has been completed.+# 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 "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \ 
 +  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null 
 +sudo apt update 
 +</code>
  
 ---- ----
  
-===== Add your user to the docker group =====+===== Install the Docker packages =====
  
 <code bash> <code bash>
-sudo usermod -aG docker $USER+sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
 </code> </code>
  
 <WRAP info> <WRAP info>
-**NOTE:**  This allows docker to be run without using sudo.+**NOTE:**
  
-To enable this functionality, log out and log back in; or run: <code bash> +  * **docker-ce** - The Docker engine itself. 
-newgrp docker +  * **docker-ce-cli** - A command line tool that lets you talk to the Docker daemon. 
-</code>+  * **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 using a single YAML file.
  
 </WRAP> </WRAP>
Line 59: Line 87:
 ---- ----
  
-===== 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
 </code> </code>
  
-<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:+
  
-<code bash+<code> 
-sudo chmod 666 /var/run/docker.sock +Unable to find image 'hello-world:latest' locally 
-</code>+latest: Pulling from library/hello-world 
 +e6590344b1a5: Pull complete  
 +Digest: sha256:0b6a027b5cf322f09f6706c754e086a232ec1ddba835c8a15c6cb74ef0d43c29 
 +Status: Downloaded newer image for hello-world:latest
  
-</WRAP>+Hello from Docker! 
 +This message shows that your installation appears to be working correctly.
  
 +To generate this message, Docker took the following steps:
 + 1. The Docker client contacted the Docker daemon.
 + 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
 +    (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: 
 + $ docker run -it ubuntu bash
  
-===== Start Docker =====+Share images, automate workflows, and more with a free Docker ID: 
 + https://hub.docker.com/
  
-<code bash> +For more examples and ideas, visit: 
-systemctl start docker+ https://docs.docker.com/get-started/
 </code> </code>
  
-----+<WRAP info> 
 +**NOTE:**  This downloads a test image and runs it in a container.
  
-===== 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 enable docker+sudo systemctl restart docker.service
 </code> </code>
 +
 +</WRAP>
  
 ---- ----
  
-===== Check the docker version =====+===== Uninstall Docker Engine =====
  
 <code bash> <code bash>
-docker version+sudo apt purge docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-ce-rootless-extras
 </code> </code>
  
-Show the currently installed Docker version.+Then, manually remove the following two directories: 
 + 
 +<code bash> 
 +sudo rm -rf /var/lib/docker 
 +sudo rm -rf /var/lib/containerd 
 +</code>
  
 ---- ----
  
-Now docker is installed in your system.+===== References ===== 
 + 
 +https://docs.docker.com/engine/install/ubuntu/ 
 + 
 +https://docs.docker.com/engine/install/ubuntu/#uninstall-docker-engine
  
-You can start making a container by downloading a Docker Image from the Docker Registry.+https://docs.docker.com/engine/network/packet-filtering-firewalls/
  
docker/install_docker.1747755654.txt.gz · Last modified: 2025/05/20 15:40 by peter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki