Skip to main content

Command Palette

Search for a command to run...

How to run Portainer GUI in Docker container

Published
2 min read
How to run Portainer GUI in Docker container
M

Hey, I'm a postgraduate in Cyber Security with practical experience in Software Engineering and DevOps Operations. The top player on TryHackMe platform, multilingual speaker (Kazakh, Russian, English, Spanish, and Turkish), curios person, bookworm, geek, sports lover, and just a good guy to speak with!

Overview:

Portainer is a lightweight management UI that allows you to easily manage your different Docker environments (Docker hosts or Swarm clusters). Portainer is meant to be as simple to deploy as it is to use.

  • OS: CentOS Linux 7 (Core)
  • Docker: Docker version 20.10.16, build aa7e414

Run portainer in Docker container:

  1. Create volume to store portainer data:
    docker volume create portainer_data
    
  2. Create the container:
    docker container run -d --name portainer -p 8080:9000 \
    --restart=always \
    -v /var/run/docker.sock:/var/run/docker.sock \
    -v portainer_data:/data portainer/portainer
    
  3. Check if container is up and running:
    docker container ls
    

Confugure GUI and container:

  1. Access GUI at http://[docker_server_url]:8080 and create a new user with password:
  2. Select Local Docker server:
  3. After connecting you will see a GUI dashboard with your local Docker server:
  4. To create a container click on local and then select Containers:
  5. Select Add container:
  6. Specify the image from your DockerHub registry and port number:
  7. Press Deploy the container and check if it's up and running:

Notes:

  1. /var/run/docker.sock is basically the Unix socket the Docker daemon listens on by default. It is also a tool used to communicate with the Docker daemon from within a container. Sometimes, containers need to bind mount the /var/run/docker.sock file. About /var/run/docker.sock
  2. --restart=always - specifies to restart the container when it is stopped

Reference:

  1. Portainer
  2. Portainer GitHub repo

More from this blog

M

Maxat Akbanov's blog

259 posts

Postgraduate in Cyber Security with experience in Software Engineering and DevOps Operations.