Docker

description: Containers with Docker.

lang: ENG

Connect to hub.docker.com

  docker login --username <user>

Connect to another website (UNSECURE way)

  TOKEN=<your website token>
  echo $TOKEN | docker login <url> -u <username> --password-stdin

Build a docker image from a Dockerfile

  docker build -t <NAME>:<VERSION> -f <FILENAME> <PATH>

Pull an image from hub.docker.com

  docker pull <image>:<tag>

Pull an image from another website

  docker pull <website_url>/<image>:<tag>

Push an image to hub.docker.com

  docker push <user>/<image>:tag

Push an image to another website

  docker push <website_url>/<user>/<image>:<tag>

Launch a container

  docker run -it --name <nom> -v <volume-local>:<volume-conteneur> \
             <image>:<tag>
  docker run --rm -d --name <nom> -v <volume-local>:<volume-conteneur> \
             -p <host-port>:<conteneur-port><image>:<tag>

Connect to a running container

	docker exec -it <tag> <command>

Get the container logs

  docker logs <name ou id>

Stop a containeur

  docker stop <name>

Save docker images

  docker commit -p <ID> tag_name
  docker save -o <name>.tar <tag_image>

Load a container from a save

  docker load -i <name>.tar

Resources