Docker: Difference between revisions

From Leo's Notes
This page was last edited on 20 July 2017, at 21:37.
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..."
 
Line 44: Line 44:
| Removes a container. Use {{code|-rf}} to stop and remove.
| Removes a container. Use {{code|-rf}} to stop and remove.
|}
|}


== See Also ==
== See Also ==

Revision as of 21:37, 20 July 2017

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