手动构建
1.关键字查找镜像
- sudo docker search centos
2.下载基本镜像
3.启动容器
- sudo docker run -d -it --name centos1 -h centos1 -p 91:80 -v /home/root:/my_python -w my_python centos /bin/bash
-
- docker container ls
4.进入容器
- sudo docker exec -it 容器id /bin/bash
5.进入更新软件
6.安装软件
7.退出
8.停止容器
9.提交镜像
- sudo docker commit -m "python3" 73795020d9d8 ubuntu-python3:3.5
- 73795020d9d8 容器id
- ubuntu-python3 名字
- 3.5 :版本号
-
dockerfile构建
1.创建Dockerfile文件 D要大写
-
-
-
-
-
- FROM centos
-
-
- LABEL maintainer="yu"
-
-
- ADD plist.txt(文件名称,这个路径,同级目录) /usr/local/src(添加到的路径)
- ADD pore-8.37.tar.gz /usr/local/src
- ADD nginx-1.9.3.tar.gz /usr/local/src
-
-
- RUN yum install -y wget gcc gcc-c++ make openssl-devel
- RUN useradd -s /sbin/nologin -M www
-
-
- WORKDIR /usr/local/src/plist.txt
- RUN pip install -r plist.txt
- RUN ./configure --prefix=/uer/local/nginx --user=www --group=www --with-http_ssl_module --with-http_stub_status_module --with-pcre=/uer/local/src/pcre-8.37 && make && make install
- RUN echo "daemon off;" >> /usr/local/nginx/conf/nginx.conf
-
-
- ENV PATH /ust/local/nginx/sbin:$PATH
-
-
- EXPOST 80/tcp
-
-
- CMD ['nginx']
-
-
2.运行Dockerfile文件
- docker build -t(取个名称) my_nginx:V2 .(Dockerfile文件路径,也可以写绝对路径)
-