1、安装docker
1 | apt install docker.io |
2、修改成国内镜像源
1 | cd /etc/docker |
重启docker服务
1 | service docker restart |
3、docker安装portainer
搜索portainer
1 | docker search portainer |
拉取portainer
1 | docker pull portainer/portainer |
创建portainer容器并启动
1 | docker run -d --name portainerUI -p 8000:9000 -v /var/run/docker.sock:/var/run/docker.sock portainer/portainer |
4、访问portainer界面
http://192.168.1.102:8000
首次登陆时,初始化设置密码。
- 安装docker
apt install docker.io
sudo systemctl enable docker
sudo systemctl start docker
sudo systemctl restart docker
- 测试:
docker run hello-world
- 通过Dockerfile构建docker image
- 获取镜像:
sudo docker pull ubuntu:18.04
- 运行镜像:
sudo docker run --net host -t -i ubuntu:18.04 /bin/bash
- 查看镜像:
sudo docker images
- 查看镜像:
sudo docker image ls
- 查看容器:
sudo docker ps -a
- 查看当前工作容器:
sudo docker ps
- 删除容器:
sudo docker rm <容器id>
- 删除镜像:
sudo docker image rm <镜像id>
- Dockerfile 创建镜像:
sudo docker build -t <镜像名称>
. - flask 启动服务: python manager.py runserver –host 0.0.0.0 –port 5000
- commit: sudo docker commit -a “liutao” -m “face_detection_v1.0” <容器id> face_detection
- save: sudo docker save -o face_detection.tar face_detection
- load: sudo docker load < face_detection.tar
- 进入容器:
sudo docker exec -it IMAGE ID或者NAMES /bin/bash
- 从容器拷贝文件到宿主机:
sudo docker cp mycontainer:/face_detection/upload ~/upload
- 从宿主机拷贝文件到容器:
sudo docker cp ~/upload mycontainer:/face_detection/upload
- 获取镜像:
- 多次测试,待程序在docker image正常运行后,可进行服务器部署
Docker ubuntu镜像更换apt-get
1 | sed -i s@/archive.ubuntu.com/@/mirrors.aliyun.com/@g /etc/apt/sources.list |