Installing Docker & Portainer

Updated 9-2-2023: fixed a few path issues

If you do not have Docker installed already, here is the link to install Docker (properly) on Ubuntu Linux:
https://docs.docker.com/engine/install/ubuntu/

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/docker-ubuntu.gpg

echo "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/trusted.gpg.d/docker-ubuntu.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

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

And to install Portainer, you can follow their official instructions:
https://docs.portainer.io/start/install-ce/server/docker/linux

But basically it comes down to the below two commands.

The second ‘docker run’ command is what you would use if you have an SSL certificate and key to use. In the second command, I am mapping the local folder /etc/ssl/private to inside the portainer docker container as /certs. So then Portainer can reference the certificates at /certs. You’ll need to change the path to match where you store the certificates.

docker volume create portainer_data

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

If you want to install Portainer with SSL support, map your SSL certificate directory (in this example, to /certs) and add the sslcert and sslkey options:

docker run -d --name portainer -p 9443:9443 --restart always -v /var/run/docker.sock:/var/run/docker.sock -v /etc/ssl/private:/certs:ro -v portainer_data:/data portainer/portainer-ce:latest --sslcert /certs/yourcert.crt --sslkey /certs/yourcert.key

Once installed, you can access Portainer at http://<machine.ip>:9443 (or https:// if using SSL)

Click on the “local” environment in the middle of the page to connect to it after logging in.

Stacks on the left hand menu is where you can go to paste Docker-Compose files which we will be using in the following guides.

Containers is where anything you start from the command line will show up (using docker run).

Leave a Comment