单机部署

1
2
3
$ docker pull portainer/portainer-ce
$ docker volume create portainer_data
$ 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
  • 打开浏览器,输入http://localhost:9000)或者http://{服务器ip}:9000
  • 设置用户名和密码后进入

Portainer升级版本

在 Portainer 安装时候是指定了数据卷的,这样一来,更新 Portainer 只需要下载新的 Portainer 的镜像,删除原有容器即可,原先的记录信息都在数据卷中。

1.关闭容器

1
$ docker stop portainer的容器名或容器Id

2.删除容器

1
$ docker rm portainer的容器名或容器id

3.确定下容器是否已经删除

1
$ docker ps -a

4.删除镜像

1
$ docker rmi portainer的镜像名或镜像Id

5.拉取新版本镜像

1
$ docker pull portainer/portainer-ce

6.启动镜像,打开浏览器输入原有帐号密码即可

1
$ 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

Portainer升级版本完整的操作日志记录

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
ubuntu@ubuntu:~$docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
fc281d660e7e portainer/portainer-ce "/portainer" 2 weeks ago Up 22 hours 8000/tcp, 9443/tcp, 0.0.0.0:9000->9000/tcp, :::9000->9000/tcp portainer
ubuntu@ubuntu:~$ docker stop fc281d660e7e
fc281d660e7e
ubuntu@ubuntu:~$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
fc281d660e7e portainer/portainer-ce "/portainer" 2 weeks ago Exited (2) About a minute ago portainer
ubuntu@ubuntu:~$ docker rm fc281d660e7e
fc281d660e7e
ubuntu@ubuntu:~$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
portainer/portainer-ce latest 9281e1907542 17 months ago 278MB
ubuntu@ubuntu:~$ docker rmi 9281e1907542
Untagged: portainer/portainer-ce:latest
Untagged: portainer/portainer-ce@sha256:47b064434edf437badf7337e516e07f64477485c8ecc663ddabbe824b20c672d
Deleted: sha256:9281e1907542d9e135476db62e7dd129a95972dc5cd297f5d01acff58c4f751f
Deleted: sha256:067f72a72d633747ba5a6039a1b4ec3d36555fa22a07f6e5c3be2940d4d040cc
Deleted: sha256:f6fe101531bcf0e63b651a4e3ce2676c1a7f1880288bb288ede04fc1deb1a8a1
Deleted: sha256:e0a46f5d05e1b93a7993c45aaea39729d111d7a096e02ac1656c721e39cb5222
Deleted: sha256:8c004456aeb58b75f792fa091b194c20d6ed4f0d95dd25b0150d71c5c9ab601b
ubuntu@ubuntu:~$ docker pull portainer/portainer-ce
Using default tag: latest
latest: Pulling from portainer/portainer-ce
57654d40e0a5: Pull complete
1f476acfabd6: Pull complete
23f2184d3136: Pull complete
e21d017187f1: Pull complete
bfa9cfee4c8e: Pull complete
9d8366b4fa62: Pull complete
d55f4e10dc55: Pull complete
5230628c9a1d: Pull complete
dd27a37dee51: Pull complete
5cc1bbad4ed2: Pull complete
4f4fb700ef54: Pull complete
Digest: sha256:4a1ceadd7f7898d9190ee0a6d22234c4323aefd80e796e84f5e57127f74370f1
Status: Downloaded newer image for portainer/portainer-ce:latest
docker.io/portainer/portainer-ce:latest
ubuntu@ubuntu:~$ 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
d6e582a7f0646ae628e15b4ee9a69f85c276d29b78cc23636b219d0f65b82f89