创建镜像
- create a Dockerfile
FROM tensorflow/tensorflow:nightly-devel-gpu-py3
RUN pip install opencv-python
RUN ["apt-get", "update"]
RUN ["apt-get", "install", "-y", "vim-tiny"]
RUN pip3 install tqdm
RUN pip3 install seaborn
WORKDIR /project_name/
COPY . /project_name/
CMD []
- create the image using the provided docker file
docker build <PATH-TO-THE-ROOT-OF-DOCKERFILE> -t <TAG-NAME>
- create a container and enter it in the terminal
docker run -it <TAG-NAME> bash
3.1. you may share home folder with the container
docker run -v <home-path>:<map-to-container-path> -it <TAG-NAME> bash
3.2. If set the CMD in the dockerfile, you could run the image directly
docker run <TAG-NAME>
- pull data from local files
scp <path-to-your-data/code> .
other usages
- display all images
docker images
- show running containers
docker ps
- close a running container
docker rm -f <CONTAINER_NAME>
- enter a runing container
docker exec -it <CONTAINER_NAME> bash
- restart a container
docker container restart <CONTAINER_NAME>