How to run Portainer GUI in Docker container

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:
- Create volume to store portainer data:
docker volume create portainer_data - 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 - Check if container is up and running:
docker container ls
Confugure GUI and container:
- Access GUI at
http://[docker_server_url]:8080and create a new user with password:
- Select Local Docker server:

- After connecting you will see a GUI dashboard with your local Docker server:

- To create a container click on local and then select Containers:

- Select Add container:

- Specify the image from your DockerHub registry and port number:

- Press Deploy the container and check if it's up and running:

Notes:
/var/run/docker.sockis 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--restart=always- specifies to restart the container when it is stopped





