Skip to main content

Posts

Showing posts from December 3, 2017

JSON on Docker

What is JSON? JSON is short for J ava S cript O bject N otation. It implements a lightweight data interchange format based on a subset of JavaScript language. JSON provides a way to store information such that it is easy for machines to parse and generate. Docker uses JSON as its default Logging Driver to communicate information. JSON is a way to store information in an organized, easy-to-access manner. It is used primarily to transmit data, as an alternative to XML . As an example of how Docker leverages JSON, here's an excerpt of the docker inspect <Name | ID> output: $ docker inspect 978d [     {         "Id": "sha256:978d85d02b87aea199e4ae8664f6abf32fdea331884818e46b8a01106b114cee",         "RepoTags": [             "debian:latest"         ],         "Container": "4799c1aee3356a0d8e51a1e6e48edc1c4ca224e55750e26916f917bdecd96079",         &quo

Docker Command Flowchart

Docker Command Flowchart Inspired by a post at www.troubleshooters.com this flowchart illustrates some of the Docker objects and the commands that apply to them. For example, to preserve changes made in a container object and convert it into an image , use the docker commit command. References: http://www.troubleshooters.com/linux/docker/docker_newbie.htm Licensed under a Creative Commons Attribution 4.0 International License .

Docker Commands: docker network

Docker Commands: docker network docker network connect Connect a running container to a network. Use docker inspect 00db80208c35 to confirm the network connection. In this case, the container is connected to two networks: Licensed under a Creative Commons Attribution 4.0 International License .

Docker Commands: docker inspect

Docker Commands: docker inspect docker inspect Return low-level information on Docker objects The target of this command is an object that can be identified via a Name or an ID , e.g. image , container , network , service , etc. The output of the command is information about the object displayed as a JSON array. @ubuntu:~ $ docker inspect wizardly_jang [ { "Id": "c794e33bda6bfa60cdc039795ad7712c62df68ca5f8a6d14b906a6a06bc08e43", "Created": "2017-04-01T06:02:04.840341671Z", "Path": "nginx", "Args": [ "-g", "daemon off;" ], "State": { "Status": "running", "Running": true, "Paused": false, "Restarting": false, "OOMKilled": false, "Dead"

Docker Commands: docker history

Docker Commands: docker history docker history <image_name> Show the history of an image. In effect, it identifies the "layers" in an image. Note: There is an online tool, imagelayers.io that can be used to visualize the layers of an image. Licensed under a Creative Commons Attribution 4.0 International License .

Docker Commands: docker diff

Docker Commands: docker diff docker diff <container ID> Inspect the changes made to a container's filesystem. Note: A Added File C Changed File D Deleted File Licensed under a Creative Commons Attribution 4.0 International License .

Docker Commands: docker exec

Docker Commands: docker exec docker exec Run a new process in an already running container Use docker exec to run a secondary process inside a container. Let's say the Nginx web proxy container is running in detached ( -d ) mode, you can use docker exec to start another process in that container. In the example below, the process status command, ps  is run inside the Nginx container. Note: If the container is stopped, it must first be started with docker start . Licensed under a Creative Commons Attribution 4.0 International License .

Docker Commands: docker commit

Docker Commands: docker commit docker commit <container ID> Containers by default are ephemeral and stateless. Changes made while in the container are discarded when the container is removed. One way to persist container updates or configuration changes, is to "freeze" the container, i.e. convert it back into an image . The docker commit command creates a new image, incorporating any changes made while a container. You can: start a container, configure it to taste, then commit those changes into a new Docker image : The new container (started from this newly generated image) reflects the changes configured in the original container. Note: Building an image via docker commit is not considered a best practice; it is not repeatable or self-documenting, like using docker build and the Dockerfile. Licensed under a Creative Commons Attribution 4.0 International

Docker Commands: docker build

Docker Commands: docker build docker build -t <DockerID>/<ImageName> <Dockerfile name> To build a new image using a Dockerfile. Using docker build is the preferred way to build a Docker Image . The build instructions are laid out in the Dockerfile, which allows an automated, documented and repeatable way to generate a specific Docker image. Associated with the docker build command is its context . The build’s context is the files at a specified location: PATH or URL. PATH is a directory on your local filesystem URL is a Git repository location A context is processed recursively, i.e. any subdirectories in the PATH and any submodules in the URL are processed for objects. By default the build instructions are read from a file called Dockerfile at the root (or top level) of your context. In the example below,  if the docker build command is run from a subdirectory ca

Docker Commands: docker info

Docker Commands: docker info docker info Display system-wide Docker information Licensed under a Creative Commons Attribution 4.0 International License .