一、手工构建Docker镜像
docker run -t -i --name=tpl ubuntu:18.04 bash
apt-get update &&\
apt-get install -y sudo vim &&\
apt-get clean
useradd -m openwrt &&\
echo 'openwrt ALL=NOPASSWD: ALL' > /etc/sudoers.d/openwrt
exit
docker diff tpl #查看该容器进行了哪些修改
docker commit -m "ubuntu 18.04" tpl yinping/ubuntu:18.04
docker run -t -i --name=tpl yinping/ubuntu:18.04 sudo -iu openwrt bash
docker attach tpl
docker exec -ti tpl sudo -iu openwrt bash
- Ctrl + d 退出并停止容器
- Ctrl + p + q 退出并在后台运行容器
docker login --username=yinping
docker push yinping/ubuntu:18.04
二、Dockerfile构建
docker build --rm -t yinping/ubuntu:18.04 .