You are currently viewing Install Docker and Portainer CE

Install Docker and Portainer CE

Some times you want to run a simple database, API or other piece of sofware ond your local enviroment, but VMs use to be a bit of a pain. Docker solve all of this, and in combination with Portainer, you obtain a pretty useful web admin GUI, so let’s get started!

First of all, Docker has a daemon known as docker engine, which is prepared to run on Linux OS, but we can also have it on Windows 11 thanks to that awesome WSL integration.

This time I’ll cover how to install Docker on both Windows and Linux.

Docker on Windows 11

Installing Docker on Windows requires an application named Docker Desktop, which you can download here.

Once download, execute the installer and just follow the needed steps. When it finishes, it asks to reboot:

Screenshot from Dockers Desktop installation process, asking for reboot when it finishes.

Once rebooted, Docker Desktop will open and ask you to accept the service agreement:

Docker Desktop screenshot asking the user to accept or deny the Docker Subscription Service Agreement.

If you are using Windows 11, maybe you get this error when accepting and trying to launch Docker Desktop:

Screenshot of a Docker Desktop error when launching it without WSL Kernel installed or not updated.

Open a terminal console or Powershell, and execute the command:

wsl --update

Once WSL is installed and updated, open the Microsoft Store application and download Ubuntu (yes, you can download Ubuntu, Fedora or Khali from Microsoft store, seems weird I know).

Then, open it and complete the installation process. It will ask for a user name to create it, and a password. Now, let’s open Docker Desktop:

Go to Docker Desktop options (top right) and go to Resources > WSL integration, this will use Linux Kernel integration instead of creating VMs. It also allows us to select which linux distribution we want to use:

Click on “Apply & restart”, wait until it loads again, and now you can open your Ubuntu distro on Windows and use Dockers commands inside it. Remember that to be able to use Docker CLI, Docker Desktop must be active and running on Windows.

Docker on Linux

I’ll be using Ubuntu 22.04 as my preferred Linux distro.Docker has several ways to install it, but the easiest one is by executing the get.docker.com SH file. This will install and configure all the needed packages that allows Docker to work properly. To do so:

curl -sSL https://get.docker.com | sh

If you don’t want to execute that script, this are the steps to manually install it, starting by updating our repos and allowing apt to use HTTPS repos

sudo apt update && sudo apt install ca-certificates curl gnupg

Now let’s add the official Docker repo GPG key:

sudo install -m 0755 -d /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

Configure Docker repo:

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

Update apt repo cache again:

sudo apt update

Time to download and install docker with the following command:

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

Check docker version:

sudo docker --version

And let’s run a test container to check it works properly:

sudo docker container run --rm hello-world

The output should look like this one:

Screenshot of a Linux terminal containing the output from a command, the output is:

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

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/
Output obtained by running Docker’s hello world container

Install Portainer CE

Portainer CE is a web GUI that allows us to view, create and operate with our containers. It can do almost everything, from volumes, services, to swarm and stacks. For now, and for local personal use, its more than enough. Portainer is also a Docker container, so we need to execute some Docker commands to run it. First, let’s create the volume where Portainer will store it’s data:

sudo docker volume create portainer_data

With this volume created, it’s time to create the container:

sudo docker run -d -p 8000:8000 -p 9443:9443 --name portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest

Let’s wait a bit so Docker downloads the image and starts the container, ant then open a web browser and go to https://localhost:9443/, and this window should appear:

Create your user and password, log in, then, this page will show up:

Select Get Started, and it’s done, you have your Portainer working:

Leave a Reply