目的
本地运行docker,进行搭建和安装必有环境之后,迁移到公共位置,例如云端。
操作步骤
安装容器
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg |sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-get install docker-ce
启动容器
我这里使用的是18.04
docker run -i -t ubuntu:18.04 /bin/bash
安装编译或其他环境
。。。。。
导出
docker export <容器id> ubuntu.tar
删除
docker -rm -f <容器 id>
迁移
cp或scp或ftp转移到目标位置
导入
cat ubuntu.tar | docker import - my_ubuntu:18.04
运行
docker run -i -t my_ubuntu:18.04 /bin/bash
查看
docker ps
恭喜你,你的镜像已经成功迁移到目的地。