If you are an IT professional and working with Docker then you may need a UI manager for docker. There are different open source tools such as rancher and portainer are available to manage different docker environments such as docker host, containers. Volumes, networks etc. In this article, we will learn how to install and configure Portainer in Ubuntu 20.04 and use it to manage docker environments.
Portainer is a lightweight UI manager for docker which can be used to manage different docker environments such as docker hosts or docker swarm clusters. Portainer runs in a single container and supports any Docker engine including Linux Container or windows native container and other platforms too. It makes it easy to manage all our Docker resources such as containers, images, volumes, networks, and more.
- Fresh ubuntu server 20.04
- Sudo privileged account
- Internet connection to download packages
Install docker on Ubuntu 20.04
In this article, I assume you have not installed docker on your ubuntu system. Follow the steps below to install docker on Ubuntu.
Update the apt package index
$ sudo apt-get update
Install the dependencies
$ sudo apt-get install apt-transport-https ca-certificates curl gnupg lsb-release
Add docker’s official GPG key
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
Now run the following command to set up the stable Docker repository.
$ echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Now update the repository index and setup docker-engine
$ sudo apt-get update
$ sudo apt-get install docker-ce docker-ce-cli containerd.io
Once the installation is completed, reboot the system
$ sudo reboot
To verify the docker installation is fine, run the simple docker image as
$ sudo docker run hello-world
Start and enable docker service
$ sudo systemctl start docker
$ sudo systemctl enable docker
Install Docker Compose
Once the docker is installed, run the following command to install docker-compose on Ubuntu.
$ sudo curl -L https://github.com/docker/compose/releases/download/1.21.2/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
Set the permission using the command:
$ sudo chmod +x /usr/local/bin/docker-compose
We have installed docker and verified by running the simple docker image. Now we will pull the docker portainer/portainer-ce image (formerly portainer/portainer) and run it as a container. Before running the container, create a persistent docker volume to store portainer data.
$ sudo docker volume create portainer_data
Now create the portainer container using the following command.
$ sudo docker run -d -p 9000:9000 -p 8000:8000 --name portainer --restart always -v /var/run/docker.sock:/var/run/docker.sock -v /srv/portainer:/data portainer/portainer-ce
- -d => Run the container in detached mode
- -p => Map the container’s port with docker host port
- –name => Name of the container
- -v => Volume Map
Please note that the screenshot still uses the old portainer/portainer package, use the new package portainer/portainer-ce instead as used in the updated command above the screenshot.
Run the following command to check the container status
$ sudo docker ps -a
Portainer is running on port 9000. Browse your server’s IP address with port 9000 in the browser and create a user.
After creating the user, you will be able to find the portainer’s dashboard. You can manage different docker resources like volumes, containers, networks and images from the UI manager
In this article, I have covered how to install portainer to manage docker using UI. We have learned how to install portainer and manage docker containers running in the docker host.
Thank you for reading.