docker

Always with sudo

How to copy Docker images?

save:
docker save -o <path for generated tar file> <image name>
load:
docker load -i <path to image tar file>
e.g.
docker save -o c:/myfile.tar centos:16

source: stackoverflow

How to run a bash in Docker?

docker run -it <image name> bash

How can I use the datasets in the host

In docker docs, there are three methods to mount.
First, I tried to create a new volume but I cannot read the dictionary because I was Permission denied.
Second, I decided to create bind mounts by
docker run <others> --mount type=bind, source=<the dir you want to mount>, target=<the dir in the container>, [readonly] <others>.

Can I change the content in my image?

  1. Do something in a container created by your image.
  2. exit or ctrl+D
  3. docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]

Why cannot I use –mount?

Because of the version of your docker.
But you can use -v instead of --mount, the command in the official document is:

1
2
3
4
5
$ docker run -d \
-it \
--name devtest \
-v "$(pwd)"/target:/app \
nginx:latest

As a sample: docker run -it -v /home/songe/datasets:/opt/dataset dlib bash.