Thursday, February 1, 2024

Install Docker On Ubuntu

 

1) Installing Docker Using the apt Repository
 
$ sudo apt update
$ sudo apt install ca-certificates curl gnupg lsb-release

  • Next, register Docker’s GPG keyring with apt. This will let apt validate the Docker packages you install.


$ sudo mkdir -p /etc/apt/keyrings
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
$ sudo chmod a+r /etc/apt/keyrings/docker.gpg

  • Now you can add the Docker package source to your system. Run the following command:

$ echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

  • Update your package lists again so apt knows the Docker packages exist:


$ sudo apt update

  • docker-ce:    the Docker Engine daemon.
  • docker-ce-cli:    the Docker CLI that you’ll interact with.
  • containerd.io:    the container runtime known as containerd that starts and runs your containers.


$ sudo apt install docker-ce docker-ce-cli containerd.io

  • Verify Docker Status


$ docker version
$ sudo systemctl status docker



2) Setting Docker Engine Permissions on Ubuntu

$ sudo groupadd docker

  • Then add yourself to it:


$ sudo usermod -aG docker $USER


2) Restart your computer to take the affect of permission.


  • Try running a docker command without sudo:


$ docker run hello-world

  • Install Docker Compose  


$ sudo apt install docker-compose


FYI : Docker Compose is a tool, that allow you to define and manage multi-container Docker applications using a YAML file and in YAML file you can define the services, their dependencies, networks, volumes, and other configurations.





No comments:

Post a Comment

testing