$ docker run --name repo alpine/git clone https://github.com/docker/getting-started.git & docker cp repo:/git/getting-started/ .
$ cd getting-started & docker build -t docker101tutorial .
$ docker run -d -p 80:80 --name docker-tutorial docker101tutorial
$ docker ps
$ docker ps -a # --all
$ docker image ls
$ docker run -di --name {} image_name # -di = detached & interactif, --name = specify container name
$ docker exec -ti container_name sh (bash is better) # for -ti option https://stackoverflow.com/questions/30137135/confused-about-docker-t-option-to-allocate-a-pseudo-tty
$ docker run -tid -p 8080:80 --name web nginx:latest # -p for port maping, map container port 80 into machine port 8080, :latest for the latest version
$ docker inspect conainer_name # (for example web from last command)
$ docker start conainer_name
$ docker stop conainer_name
$ docker rm -f container # -f forcing even the container is running
It serves to keep a folder from the machine synchronized with a folder in the container.
$ docker run -v local_directory_path:containter_directory_path
Usage: docker volume COMMAND
Manage volumes
Commands:
create Create a volume
inspect Display detailed information on one or more volumes
ls List volumes
prune Remove all unused local volumes
rm Remove one or more volumes
$ docker volume create volume_name
$ docker volume inspect volume_name
$ docker run (-tid --name container_name -p xxxx:xxxx) --mount source=volume_name, target=containter_directory_path image_name
$ docker volume rm volume_name (must be not used in a container)