Portainer is my favorite docker management tool, actually only one I used. If you have better one, please let me know. This post is to summarize some usage during playing with application.

  • Install Docker and Portainer
  • Update Portainer
  • Check Containers
  • Log into Container
  • Install Network Utilities in Container

[Updated on Mar 6 2021]

Some related posts:

Install Docker and Portainer

By default, Portainer store its data inside the container in the /data folder on Linux (C:\\data on Windows).
You’ll need to persist Portainer data to keep your changes after restart/upgrade of the Portainer container.  Docker Deploy document: https://portainer.readthedocs.io/en/latest/deployment.html . You can use a bind mount on Linux to persist the data on the Docker host folder:

1  Install Docker. For other linux release, commands can be found here.
#For Ubuntu 20.04 version
#Ubuntu 20.04
sudo apt install docker.io
sudo apt install docker-compose

Or Other Linux Versions:
#CentOS 7, Debian, Ubuntu 18.04/16.04
curl -sSL https://get.docker.com/ | sh 
systemctl start docker 
systemctl enable docker

2  Install Portainer

root@Ubuntu18:/# docker volume create portainer_data
root@Ubuntu18:/# docker run -d -p 9000:9000 --name portainer --restart always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest
root@Ubuntu18:/# which docker
root@Ubuntu18:/# find . -type d -name "portainer_data"
./var/lib/docker/volumes/portainer_data

or in CentOS:
[root@centos-nextcloud-aria2 ~]# find / -type d -name “portainer_data”
/var/lib/docker/volumes/portainer_data

You can try out the public demo instance: http://demo.portainer.io/ (login with the username admin and the password tryportainer).

Update Portainer

1. Update image

Old portainer/portainer repository is the home of v1.24.x, which has been deprecated. All new releases for Portainer 2.0 will be published in portainer/portainer-ce

root@Ubuntu18:/# docker stop portainer
portainer
root@Ubuntu18:/# docker rm portainer

If you only do start portainer, it won’t use the latest image to start. You will have to remove old version container, then create a new portainer with downloaded new image.

root@Ubuntu18:/# docker start portainer
portainer

some os, you might need to use command “docker pull docker.io/portainer/portainer-ce”

If you could not find image, just use command “docker search portainer-ce”



[root@centos7-docker-portainer ~]# docker search portainer-ce
NAME                           DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
portainer/portainer            This Repo is now deprecated, use portainer/p…   2033
portainer/portainer-ce         Portainer CE - Making Docker and Kubernetes …   398
thibaudlabat/portainer_32      Portainer built for 32bit Linux [ OUTDATED ]…   1
thibaudlabat/portainer-ce-32   32-bit / x86 portainer-ce                       0
terryromeu3sr/portainer-ce                                                     0
luomoxu/portainer-ce-cn                                                        0
nativeit/portainer-ce                                                          0
6053537/portainer-ce                                                           0
hanlahanla/portainer-ce                                                        0


Or:

 docker service update --image portainer/portainer-ce:latest portainer

2. Start Container with new image


[root@centos7-docker-portainer ~]# docker run -d -p 9000:9000 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce
Unable to find image 'portainer/portainer-ce:latest' locally
latest: Pulling from portainer/portainer-ce
94cfa856b2b1: Pull complete
49d59ee0881a: Pull complete
527b866940d5: Pull complete
Digest: sha256:5064d8414091c175c55ef6f8744da1210819388c2136273b4607a629b7d93358
Status: Downloaded newer image for portainer/portainer-ce:latest
90212707d5a674ef3ba23588f25b014cea60b25e0f1826ed06e09ec568930b0a


3. Delete old image
Docker image ls
docker image rm <Repository name>



root@opc-ubuntu-docker:~# docker image ls
REPOSITORY               TAG                 IMAGE ID            CREATED             SIZE
portainer/portainer-ce   latest              96a1c6cc3d15        4 weeks ago         209MB
portainer/portainer      latest              62771b0b9b09        7 months ago        79.1MB
nginx                    latest              e791337790a6        10 months ago       127MB
root@opc-ubuntu-docker:~# docker image rm portainer/portainer
Untagged: portainer/portainer:latest
Untagged: portainer/portainer@sha256:f8c2b0a9ca640edf508a8a0830cf1963a1e0d2fd9936a64104b3f658e120b868
Deleted: sha256:62771b0b9b0973a3e8e95595534a1240d8cfd968d30ec82dc0393ce0a256c5f3
Deleted: sha256:c291f08e07bbfde10ee7ae7a9c618ebedc5e5c4b3ab494b0636fb260e2a20717
Deleted: sha256:dd4969f97241b9aefe2a70f560ce399ee9fa0354301c9aef841082ad52161ec5
root@opc-ubuntu-docker:~# docker image ls
REPOSITORY               TAG                 IMAGE ID            CREATED             SIZE
portainer/portainer-ce   latest              96a1c6cc3d15        4 weeks ago         209MB
nginx                    latest              e791337790a6        10 months ago       127MB



YouTube Video:

A useful command to get rid of the stopped containers:


docker rm `docker ps -a -q`

Check Containers


root@Ubuntu18:/# docker container ls -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES
a9ea9891aa03        nginx:latest        "nginx -g 'daemon of…"   4 weeks ago         Up 4 weeks          0.0.0.0:80->80/tcp       nginx1
4cf95554b471        4cda95efb0e4        "/portainer"             4 weeks ago         Up 11 minutes       0.0.0.0:9000->9000/tcp   portainer
root@Ubuntu18:/# docker stats
CONTAINER ID        NAME                CPU %               MEM USAGE / LIMIT     MEM %               NET I/O             BLOCK I/O           PIDS
a9ea9891aa03        nginx1              0.00%               3.172MiB / 982.2MiB   0.32%               64.1MB / 132MB      14.6MB / 0B         3
4cf95554b471        portainer           0.01%               11.3MiB / 982.2MiB    1.15%               4.55MB / 50.2MB     90.7MB / 238MB      10

Log into Container

[root@centos1docker ~]# docker ps
CONTAINER ID        IMAGE                 COMMAND                  CREATED             STATUS              PORTS                    NAMES
26a4cc3a312a        nginx:latest          “nginx -g ‘daemon of…”   24 hours ago        Up 16 minutes       0.0.0.0:80->80/tcp       portainer-nginx1
d5c3f33bd8ee        portainer/portainer   “/portainer”             25 hours ago        Up 25 hours         0.0.0.0:9000->9000/tcp   portainer
[root@centos1docker ~]#

[root@centos1docker ~]# docker exec -it portainer-nginx1 /bin/bash
root@26a4cc3a312a:/#
root@26a4cc3a312a:/# cat /etc/os-release
PRETTY_NAME=”Debian GNU/Linux 10 (buster)”
NAME=”Debian GNU/Linux”
VERSION_ID=”10″
VERSION=”10 (buster)”
VERSION_CODENAME=buster
ID=debian
HOME_URL=”https://www.debian.org/”
SUPPORT_URL=”https://ift.tt/1RFz0Q5″
BUG_REPORT_URL=”https://ift.tt/1RL0g2w”

root@26a4cc3a312a:/# uname -a
Linux 26a4cc3a312a 3.10.0-1062.9.1.el7.x86_64 #1 SMP Fri Dec 6 15:49:49 UTC 2019 x86_64 GNU/Linux

Install Network Utilities in Container

Most of times, the docker image is not including following network utilities which can help you troubleshooting your network connectivity, such as ping, ifconfig, tracert, telnet etc. You might want to install them for yourself.

root@26a4cc3a312a:/# apt-get update
root@26a4cc3a312a:/# apt-get install iputils-ping
root@26a4cc3a312a:/# apt-get install telnet
root@26a4cc3a312a:/# apt-get install traceroute
root@26a4cc3a312a:/# apt-get install net-tools

Note: net-tools will include ifconfig / netstat commands

from Blogger //blog.51sec.org/2019/11/portainer-and-docker-usage.html

By Jon

Leave a Reply