Skip to main content

Debian Install Docker

Installing Docker in Debian or Ubuntu, it is very simple, but the potential of containers is huge, more and more developers, systems support them and so do we with Docker Consulting
It is available in all Linux distributions, macOS, even Microsoft supports containerization with Windows Subsystem for Linux WSL

Installing Docker in Docker

Installation requires some additional packages and enabling the official project repository
We can copy the lines and run them as user or root

  1. Let's install the requirements

    $ sudo apt-get install -y --no-install-recommends apt-transport-https ca-certificates curl software-properties-common
  2. Let's remove any conflicting packages

    $ for pkg in docker.io docker-doc docker-compose podman-docker containerd runc; do sudo apt-get remove $pkg; done
  3. Let's import the Docker repository key

    $ sudo install -m 0755 -d /etc/apt/keyrings
    $ sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
    $ sudo chmod a+r /etc/apt/keyrings/docker.asc.
  4. Let's add the Docker repository

    echo \
      "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \
      $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ \
      sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
  5. Let's update the available packages again

    $ sudo apt-get update
    
  6. Let's install the Docker packages

    $ sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Run the first container

Finished the installation of Docker this point we can run the first Docker container

$ sudo docker run -en --entrypoint bash debian

We will be looking at the shell of our newly created Debian container
To see the list of containers created we can use

$ sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0b4aacdb44b9 debian "bash" 30 seconds ago Up elegant_lovelace

Stopping a container

To stop a container we can use docker stop followed by the container name. The status from "Up" will change to "Exited" for example:

$ sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0b4aacdb44b9 debian "bash" 30 seconds ago Up elegant_lovelace
$ sudo docker stop elegant_lovelace
$ sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0b4aacdb44b9 debian "bash" 30 seconds ago Exited elegant_lovelace

Removing a container

You must use docker rm and the container name, obtained from ps -a, the container to be deleted must first be stopped

$ sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0b4aacdb44b9 debian "bash" 30 seconds ago Exited elegant_lovelace
$ sudo docker rm elegant_lovelace

Docker update a container

To update the container image simply pull it, you use the same command to download from the official repository with the syntax docker pull nomecontainer:version

$ sudo docker pull debian:latest
latest: Pulling from library/debian
d6ff36c9ec48: Pull complete
Digest: sha256:1e74c92df240634a39d050a5e23fb18f45df30846bb222f543414da180b47a5d
Status: Downloaded newer image for debian:latest
docker.io/library/debian:latest

From the moment we create a container the newly downloaded updated image will be used

Customized Docker support

Simplify the management of your Docker containers with our advanced technical support. Maximum reliability for your operations!

Contact a Docker Technician now: Free 30m consultation!

Frequently Asked Questions FAQ

How to install Docker in Kali Linux?

Installing Docker in Kali Linux follows the same process as Debian, since Kali is based on Debian. Run the commands listed in the previous section. Make sure your system is up to date before you start:
$ sudo apt update && sudo apt full-upgrade

How to start the Docker daemon in Debian?

To start the Docker service in Debian, use the command:
$ sudo systemctl start docker

To enable it at system startup:
$ sudo systemctl enable docker

Check the status of the service with:
$ sudo systemctl status docker

Can I install a Linux system inside a Docker container?

Not really, you can use a minimal Linux distribution inside a Docker container. For example, to start a Debian-based container, use the command:
$ sudo docker run -it debian
This will provide you with an isolated Debian-based environment. You can choose from several Linux distributions available on the Docker Hub, such as Ubuntu, CentOS, or Fedora.

Add new comment

Comment

  • Allowed HTML tags: <br> <p> <code class="language-*"> <pre>
  • Lines and paragraphs break automatically.
  • Only images hosted on this site may be used in <img> tags.