How To Install Docker on an AWS Instance of SUSE Linux?

Updated on 12/26/18

These directions show how to install Docker on SUSE Linux. These commands are for installing Docker 1.x on an AWS instance of SUSE 15.  These directions require that your AWS SUSE Linux server is in a security group that has access to the internet.  (If you want to see more directions for install Docker on different distributions of Linux in different public clouds, see this posting.)

Step #1 

How Do You Upload Files to Nexus 3 in a Docker Container on Linux CentOS?

Problem scenario
You want to upload files into Nexus 3 running in a Docker container.  You installed Nexus 3 with Docker 1.9 using these directions. The OS is CentOS 7.2.  The web UI for Nexus 3 works via Docker, but you cannot upload files into any repository. When you go to Repositories, but you do not see the “Artifact tab.”  How do you upload files?

Solution
Prerequisite
Install Docker;

How Do You Create Docker Containers To Have Unique IP Addresses?

Problem scenario
How do you create Docker containers to have unique IP Addresses (but not the default 172.x.x.x type)?

Solution
(If you need help installing Docker, see this posting.)

Create new IP addresses with these commands (with sudo in front of them, preferably, or less preferably as the root user):

ip addr add 33.33.33.38/28 brd + dev eth0
ip addr add 33.33.33.39/28 brd + dev eth0
ip addr add 33.33.33.40/28 brd + dev eth0

# Replace the IP addresses and subnet masks as you desire

Then use a modified version of this command:
docker run -p 33.33.33.38:80:80 repositoryName:versionDesignation /bin/bash
# You can use the “docker images” command to find the “repositoryName” and “versionDesignation”
# The IP address and port mapping (from Linux server to Docker container) can be substituted as needed

Two or more containers on the same Docker host can use port 80 using this method. 

How Do You Troubleshoot the Docker problem “Error response from daemon: Cannot start container”?

Problem scenario
Sometimes you try to start a Docker container but there is a problem.  For example you try:
docker start <containerID
But you receive this: “Error response from daemon: Cannot start container <containerID: failed to create endpoint <nameon network bridge: ip tables failed: iptables –wait -t nat -A DOCKER -p tcp -d 0/0 –dport 80 -j DNAT –to-destination x.x.x.x:80 ! -i docker0: iptables: No chain/target/match by that name.”

Solution
cd /var/lib/docker/network/files/
ls -lh /tmp/forposterity
mkdir /tmp/backupdir
mv /var/lib/docker/network/files/ /tmp/backupdir
systemctl restart docker
 #change this command depending on your distribution and version of Linux to restart Docker services

Saving a Docker Image and Using It On A Different Server

Problem Scenario
Sometimes the “docker save” command does not work as you would expect.  You run the command on a Docker host, but it does not work.  You might even try the -o flag or the –output=/tmp/destinationFileName.tar option.  But the response may be an surprising error “Cowardly refusing to save to a terminal. Use the -o flag or redirect.”  You want to copy a Docker image from one machine to another computer but problems get in your way. 

Having Two Docker Containers Share A Directory on the Host

Goal: You want two Docker containers to use the same file share on the Docker server from time to time.  

Problem/Error blocking goal:  In a Docker container, when you try to change directories to a directory that is on the Docker host (e.g., the docker container was created with the –volume flag), and you get an error “bash: cd <directoryname> permission denied,” you have to run two commands to fix it. 

How To Fix a Docker Container That Is Giving An Error ‘exec “bash”: executable file not found in $PATH’

Normally you can enter a Docker container with this command:
docker exec -it <containerIDbash
It is possible you receive an error that says ‘exec “bash”: executable file not found in $PATH’
The root cause could be related to insufficient disk space on the Docker host.  Delete files or otherwise make room (e.g., add disk space).  Then stop the container with this command: docker stop <containerID
Finally,

How To Have The Apache Service Automatically Start When Its Docker Container Is Started

Goal:  To have Apache start when a Docker container starts running do the following (for Docker containers based on RHEL/CentOS/Fedora). 

Prerequisite:  The Docker container was created with the “-p 80:80” flag.  Other port numbers besides 80 will work.  The port numbers do not have to be the same.  They can be any number between 1 and 65535.  If there is no binding of the Docker host’s TCP ports to the container,

How A Docker Container and Its Server Can Share a Directory

Create the Docker Container with this:

docker run -i -v /absolute/path/on/DockerHost:/absolute/path/in/Docker/Container -t repositoryName /bin/bash

where “/absolute/path/on/DockerHost” is the path and directory on the Docker server that will be presented to the Docker container in the location of “/absolute/path/in/Docker/Container.”

The “repositoryName” in the example is found by running this command: docker images
In the results of this command under the left-hand column are the potential repositoryName values.

Concerns About Creating a Docker Container With Optional Flags

Some online Docker literature suggests creating a new Docker container (e.g., the “docker run” command) with these two options:

–net=host –privileged=true

There are some caveats with these flags.  First, if you use them, within your container you can make changes to the Docker server itself.*  For some applications, this defeats Docker’s purpose.  Secondly, if the application you run in Docker becomes compromised, the entire host could be vulnerable to an attack through the Docker container.*