Docker

From Leo's Notes
Revision as of 21:35, 20 July 2017 by Leo (talk | contribs) (Created page with " == Installation == Install docker using your package manager and then start the service. To play with docker, you will need to run things as root or be part of a group that...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
This page was last edited on 20 July 2017, at 21:35.

Installation

Install docker using your package manager and then start the service.

To play with docker, you will need to run things as root or be part of a group that has access to docker's socket.

See more here: https://docs.docker.com/engine/installation/linux/linux-postinstall/


Usage

Command Description
docker images Lists docker images that you created or pulled using docker pull
docker pull Pulls a docker image from docker.io
docker run Runs a command in a container. Eg. docker run alpine ls -l
  • For commands that require an interactive shell, pass in -it.
  • Pass in --name for a custom name instead of a long hash
  • Pass environment vars using -e
  • Pass -d to detach immediately
  • Pass -P to specify the image
docker ps Lists containers that are running.

Pass -a to see all containers that executed.

docker port shows the port mapping between the container and the host.
docker stop Stop a container
docker kill ??
docker rm Removes a container. Use -rf to stop and remove.


See Also