Docker Admin Cheat Sheet part 1

container-lockHere is part one of a personal docker administration cheat sheet I have been putting together. I know there are a number of sites that provide similar tools, but for my own purposes, its easier to remember different commands when I organize them myself.

Docker administration cheat sheet

Docker images are a source file (like an .ISO) that is used to start a container (an installed system). Periodic maintenance is necessary because a Docker container remains on your system even after it exits.

What’s running?

Show all running local containers with container id, image it’s based on, any open ports, commands that it runs on startup, and when it was created.

  • Docker ps

Show all local containers (running or not) with short container id, image it’s based on, any open ports, commands that run on startup, and when it was created

  • Docker ps –a or -l

Show only the container id of all local containers (running or not running).

  • Docker ps -aq or -lq

Show the same info as –a or –l but with the full container ID rather than the shortened one.

  • Docker ps –a –no-trunc

Pause the container with the specified ID (which you can get with the ps command)

  • Docker pause <container id>

Restart a previously paused container with the specified ID (which you can get with the ps command)

  • Docker start <container id>

Local Images

Show all locally stored image files, with a common name (referred to as a repository), a 12 character ID, the size of the image file and how long ago the image was created. There may also be a tag indicating the image file version

  • Docker images

Shutdown containers

Gracefully shut down an active container with the id or short name (which you can get with the ps command) – this is preferable to kill.

  • Docker stop <container ID> or <name>

If stop doesn’t work you can forcefully shut down an active container with the id or short name (which you can get with the ps command)

  • Docker kill <container ID> or <name>

To force a shut down of a running container and delete it

  • Docker rm –f <containerID>

Cleanup

Delete the container identified with the specified ID (which you can get with the ps command)

  • Docker rm <container id>

Delete a docker image file (a source file for containers) identified with the specified id (which you can get with the ps command)

  • Docker rmi <image name>

To delete all of the containers on your local system (be careful!), use this command

  • Docker rm $(docker ps –a –q)

That’s all for now! Coming up I have posts on running containers, and how to attach the host file system as a volume in a container.

Photo Break – Mansfield Reformatory

DSC_4229
DSC_4348

Above are a couple of pictures I took during a photography workshop at the Mansfield Reformatory in Mansfield Ohio. Erected in the late 1800s, the prison was closed a few decades ago but is maintained as an historic site.  In the intervening time its been used as the setting for a number of movies, most notably the Shawshank Redemption. It was a fascinating experience and if you are near Mansfield Ohio I recommend stopping in for a tour.

BTW – my apologizes for the dearth of posts lately, but some recent changes has left me with a serious shortness of free time.

Cannot connect to the Docker daemon – fixed!

containersA quick note this time around: After installing Docker on my Linux Mint laptop, I wanted to be able to run it with my normal user account and not have to SUDO every time I wanted to start a container. (Please be advised that doing so can be considered a HUGE security hole, but since I am just testing Docker, I was willing to risk it).

In order to do this, all of the documentation I found said to create a Docker group, and then add my user account to that group, and restart. This is fairly simple to accomplish with the GUI Users and Groups tool. The Docker daemon then uses that group to see if the user account has permissions to start Docker and connect to the daemon. The result? I would get this error: Cannot connect to the Docker daemon. Is ‘docker daemon’ running on this hostAfter trying several things, I finally found the solution.

  1. From a terminal prompt run this command:
    echo $DOCKER_HOST

    You should see a line indicating your Docker host is set to an IP address. You will need to clear it.

  2. At the terminal prompt, switch  to your home folder:
    cd ~
  3. Now, edit your shell profile:
     nano ./.profile
  4. Look for a line like this:
     export DOCKER_HOST=tcp://127.0.0.1:4243
  5. Add a comment marker (#) before it or delete the line completely. Save your profile file and exit.
  6. Restart your system, and you should now be able to run Docker using your normal user account.

 

 

Install the Tor Browser on Linux

DCF 1.0

The TOR project was started by United States Naval Research Lab employees in the early part of the 21st century as a way to protect intelligence communications  online. It was open sourced in 2004, and continues to be supported by the Electronic Frontier Foundation. As privacy as continued to decline on the Internet, interest in the Tor Browser and Tor project has increased. For more information on TOR see this recent article at Salon.com.

I would like to note that I don’t support or condone the use of TOR for illicit or illegal purposes, but for those who feel that their privacy is important , I am providing these instructions for how to install the Tor Browser on Linux. These instructions should work for most Linux distros.

Continue reading