创建ubuntu docker镜像
1. 创建Dockerfile
[dongfeng@localhost test]$ cat Dockerfile
FROM ubuntu:18.04
MAINTAINER The UbuntuOS Project <dongfeng@baicells.com>
ENV container docker
ENV LC_ALL C
ENV DEBIAN_FRONTEND noninteractive
RUN sed -i 's/# deb/deb/g' /etc/apt/sources.list
RUN apt-get update -yqq \
&& apt-get install -yq apt-utils \
&& apt-get install -yq curl \
&& apt-get install -yq git \
&& apt-get install -yq unzip zip tar \
&& apt-get install -yq ca-certificates \
&& apt-get install -yq bash-completion \
&& apt-get install -yq iproute2 iputils-ping \
&& apt-get install -yq systemd systemd-sysv \
&& apt-get clean \
&& apt-get autoclean \
&& apt-get autoremove \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN cd /lib/systemd/system/sysinit.target.wants/ \
&& ls | grep -v systemd-tmpfiles-setup | xargs rm -f $1
RUN rm -f /lib/systemd/system/multi-user.target.wants/* \
/etc/systemd/system/*.wants/* \
/lib/systemd/system/local-fs.target.wants/* \
/lib/systemd/system/sockets.target.wants/*udev* \
/lib/systemd/system/sockets.target.wants/*initctl* \
/lib/systemd/system/basic.target.wants/* \
/lib/systemd/system/anaconda.target.wants/* \
/lib/systemd/system/plymouth* \
/lib/systemd/system/systemd-update-utmp*
VOLUME [ "/sys/fs/cgroup" ]
CMD ["/lib/systemd/systemd"]
2. 构造镜像
docker build -t ubuntu18.04-base .
3. 给镜像打tag
docker tag ubuntu18.04-base:latest workerwork/ubuntu18.04-base:latest
4.登录dockerhub
在web上登录创建新的仓库workerwork/ubuntu18.04-base,然后执行
docker login --username=workerwork
5.上传镜像
docker push workerwork/ubuntu18.04-base:latest
6.下载镜像
docker pull workerwork/ubuntu18.04-base:latest
7.使用镜像
sudo docker run -d --privileged=true -v /sys/fs/cgroup:/sys/fs/cgroup --name=ubuntu workerwork/ubuntu18.04-base
sudo docker exec -it ubuntu /bin/bash