Skip to content

Instantly share code, notes, and snippets.

@lucamartellucci
Last active March 11, 2016 15:01
Show Gist options
  • Save lucamartellucci/51f5c1bdedb7a5ca3534 to your computer and use it in GitHub Desktop.
Save lucamartellucci/51f5c1bdedb7a5ca3534 to your computer and use it in GitHub Desktop.
Docker Mini-How-To

Docker how-to

Start / Stop the docker service

$ service docker start / stop

Sign in to the Docker Hub

$ docker login

Show the running Docker containers

$ docker ps

Show all the docker containers

$ docker ps -a

Show the available docker images

$ docker images

Create a docker container based on the Redis image

If the Redis image is not available on the host it is downloaded from the Docker hub. The -d option is used to send the container to the background.

$ docker run --name myredis -d redis

Get the IP address of a container

$ docker inspect -f '{{ .NetworkSettings.IPAddress }}' myredis

Start / stop a docker container

$ docker start / stop myredis

Destroy a container

$ docker rm myredis

Execute Postgresql into a docker container and launch psql:

$ docker run --name some-postgres -e POSTGRES_PASSWORD=mysecretpassword -d postgres

Connect to a running Postgresql container

$ docker run -it --link some-postgres:postgres --rm postgres sh -c 'exec psql -h "$POSTGRES_PORT_5432_TCP_ADDR" -p "$POSTGRES_PORT_5432_TCP_PORT" -U postgres'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment