启动容器:docker run -dit --name XXX mysql:5.6 /bin/bash,XXX表示容器名
进入容器:docker exec -it XXX /bin/bash
导出镜像:docker save -o hx_mysql.tar hx_mysql:v0.1
导入镜像:docker load -i hx_mysql.tar
挂载数据卷:docker run -dit -v /docker/mysql_data:/home/mysql_data --name XXX mysql:5.6 /bin/bash
-v后面的目录为绝对路径
指定端口:docker run -dit -p 1234:80 --name XXX mysql:5.6 /bin/bash
容器与宿主机共享网卡:docker run -dit --network=host --name XXX mysql:5.6
基于容器创建镜像(不推荐):docker commit XXX hx_mysql:v0.1
例子:
docker run -dti -p 80:5000 -v /root/docker/teeth_project:/app --name=teeth-web-container python:3.6 /bin/bash
docker exec -it teeth-web-container /bin/bash
使用Dockerfile创建镜像:
docker build -t hx_mysql:v0.1 /dockerfile/nginx/
Dockerfile文件存放在/dockerfile/nginx/目录下
docker build -t hx_mysql:v0.1 .
.表示Dockerfile文件存放在当前目录
Dockerfile例子:
FROM ubuntu
ADD ./requeriment.txt /home
WORKDIR /home
ADD ./sources.list /etc/apt/sources.list
RUN apt-get update && apt-get install -y python3-pip && pip3 install -r requeriment.txt
ADD ./teeth /home/teeth
WORKDIR /home/teeth
EXPOSE 5000
ENTRYPOINT gunicorn -w 2 -b 0.0.0.0:5000 main:app
CMD ["/home/start.sh"]
设置pip源
pip config set global.index-url http://mirrors.aliyun.com/pypi/simple
pip config set install.trusted-host mirrors.aliyun.com
安装paddle依赖
python3 -m pip install paddlepaddle -i https://mirror.baidu.com/pypi/simple
pip install cython
pip install git+https://gitee.com/jiangjiajun/philferriere-cocoapi.git#subdirectory=PythonAPI
pip install paddlex -i https://mirror.baidu.com/pypi/simple
pip install matplotlib
设置.sh文件权限(没有权限无法执行)
chmod +x start.sh