What Is a docker-compose.yml File?

Question
What is a docker-compose.yml file?

Answer
It is a file used by the docker-compose utility which orchestrates the creation of multiple containers. For microservices, SOA and various stacks of applications (e.g., the LAMP stack), container orchestration is useful. Here are some quotes which help elucidate what docker-compose does:

“Compose is a tool for defining and running multi-container Docker applications.” (Taken from Docker’s website.)

“In order to do something useful with containers,

How Do You Connect to a Particular Docker Repository or Registry to Run a “docker push” Command?

Problem scenario
You want to use the “docker push” command. But you do not know how your Docker host is configured. You want to know what repository your Docker host is configured to use. How do you determine which repository your “docker push” commands will be destined to?

Solution
Docker push involves a destination Docker registry — not a repository. A registry is a collection of Docker repositories (things that hold versions of Docker images).

How Do You Install Docker on Debian Linux in GCP?

Problem scneario
In Google Cloud Platform you have a Debian Linux server. You want to install Docker on it. What do you do?

Solution
1. Create a file called dockerinstall.sh in the /tmp/ directory with the following content:

apt-get -y update
apt-get install -y apt-transport-https ca-certificates wget software-properties-common

wget https://download.docker.com/linux/debian/gpg
apt-key add gpg

echo “deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable” | sudo tee -a /etc/apt/sources.list.d/docker.list
apt-get -y update

apt-get -y install docker-ce

2.

How Do You Create a Dockerfile That Will Use Reserved Words Such as FROM, RUN, COPY, WORKDIR, ADD, and LABEL?

Problem scenario
You want to create your own Dockerfile. You also want to invoke reserved words such as FROM, RUN, COPY, WORKDIR, ADD, and LABEL. You want to then create a Docker image from it. You want to ultimately create a working Docker container from that image. How do you do all of this?

Solution

1. In a given directory,

How Do You Enter a Docker Container That is Currently Running?

Problem scenario
You want to get inside a Docker container that is running.  You are on the Docker host.  What should you do?

Solution
1.  Run this command:  docker ps -a   # Find the container ID in the output
2.  Run this command but substitute abcd1234 with the container ID found above:
docker exec -it abcd1234 bash

How Do You Create a Node.js Application to Be Presentable and Usable via a Docker Container?

Problem scenario
You want to create a basic “Hello World” web page with Node.js running in a Docker container.  How do you do this?

Solution
Prerequisite

Install Docker.  If you need assistance, see this posting.

Procedures
1.  Create three files in the same directory on a Linux server. 

How Do You Secure a Docker Container, a Docker Host, and Their Network?

Problem Scenario
You have been tasked with finding ways of securing Docker containers, a Docker host, and your network that has Docker containers.  How do you harden a Docker container and its related infrastructure (i.e., the Docker network and Docker host)?

Solution
Overview

From a pragmatic perspective we understand that there are exceptions to the recommended practices.  (Not the least of which is the rapid rate that technology changes.)  The assertions below are recommended practices. 

How Do You Troubleshoot “Redirecting to /bin/systemctl start docker.service ==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units”?

Problem Scenario
You try to configure Docker such that you can run “docker” commands without sudo.  You run these three commands:

sudo groupadd docker
sudo gpasswd -a $USER docker
newgrp docker

You then installed Docker and rebooted the server.  You then run this:

docker run hello-world

But you received this:

/usr/bin/docker-current: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.

How Do You Use docker-compose?

Problem scenario
You want to create an example of a docker compose file.  How do you use docker-compose?

Prerequisites
i.  This assumes you have Docker installed and running.  If you need assistance, see this posting.
ii.  This assumes that you have installed docker-compose.  If you need assistance, see this posting.
iii.  This assumes the Docker host has access to the internet.

How Do You Get Jenkins Working in a Docker Container?

One of the following problems apply:

Problem scenario #1
You have no idea how to start Jenkins in a Docker container.  What should you do?

OR

Problem scenario #2
You have run some Docker commands to try to start deploy Jenkins in a container.  You get output like this:

[4213] [10236] Disconnected
[9146] Connection from [::1]:41118
[9146] Extended attributes (16 bytes) exist <host=localhost>