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>

How Do You Delete Servers in AWS with Python?

Problem scenario
You want to write a Python program to delete servers.  How do you delete EC-2 instances in AWS with Python?

Solution
Prerequisites

a.  You have installed Boto3.  If you do not know how, see this posting
b.  You know the instance IDs.  If you do not know them, see this posting.

Procedures
Read the “Usage instructions” of this Python program we call “deleteec2.py”.

How Do You Run a Docker Container as a Non-root User?

Problem scenario
You run this command: docker run -it ubuntu bash

docker: Got permission denied while trying to connect to the Docker daemon sockes/create: dial unix /var/run/docker.sock: connect: permission denied.

You do not want to run a Docker container as a privileged user (as a recommended practice).  What should you do?

Solution
Background: “To do builds in the cluster,

How Do You Troubleshoot an ldapsearch -x command Returning “No such object”?

Problem scenario
You want to test your OpenLDAP configuration.  You run an “ldapsearch -x” command in hope that it wil l return a “Success.”  You run the “ldapsearch -x” command, and you see this:

“# search result
search: 2
result: 32 No such object”

What should you do?

Solution
Verify your /etc/ldap/ldap.conf is configured correctly.  The BASE stanza should have one or possibly three “dc=” entries separated by commas.

How Do You Troubleshoot the Bash Error “unary operator expected”?

Problem scenario
You run a Bash script with an if condition that uses the -Z flag.  It looks like this:

if [ $foovar -Z ]; then

The script seems to run with an ignorable error message “unary operator expected”.  How do you get this error to not appear?

Solution
Use ‘= “”‘ instead of “-Z”.  Here is one way to re-write the if condition above:

if [ $foovar = “” ];

How Do You Troubleshoot the Error “ERROR 1273 (HY000): Unknown collation: ‘utf8mb4_general_ci6′”?

Problem scenario
You are trying to follow the Drupal installation instructions.  You run this command from a mysql prompt:

mysql> CREATE DATABASE drupaldb CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci6;

But you get this error: “ERROR 1273 (HY000): Unknown collation: ‘utf8mb4_general_ci6′”

What should you do?

Solution
To find the potential collations that you can run (based on your SQL database), run this command:  

SHOW COLLATION;

What Is a Quick Way to Get All of Your Emails in One File from a Web-based Email Provider?

Problem scenario
You have a web-based email provider.  You want to save all of your emails in one location quickly.  How do you download them into one file?

Solution
If there are maximum size limits for sending a single email (e.g., 25 MB), this method may not work if all of your emails put together exceed this size limit.*

1.  Click an option to select all emails. 

How Do You Fix Broken Packages on Debian Linux to Be Able to Use The apt Command as Normal?

Problem scenario
This command is not working for you:  sudo apt –fix-broken install

You get a message like this:

dpkg: error processing archive /var/cache/apt/archives/puppet_4.8.2-5_all.deb (–unpack):
 trying to overwrite ‘/lib/systemd/system/puppet.service’, which is also in package puppet-agent 5.4.0.522.g6baf971-1xenial
dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
Errors were encountered while processing:
 /var/cache/apt/archives/puppet_4.8.2-5_all.deb

You try this command:
sudo apt-get purge -s puppet*

You cannot remove a package. 

How Do You Get the Curl Command to Work like wget when the URL Has a Forwarding 300 Series Return Code?

Problem scenario
You do not want to install wget on Linux.  You want curl to download a file from the internet.  How do you get curl to work through a forwarding request the same way wget natively works?

Solution
Use the “-L” flag.   For example:

curl -L www.continualintegration.com > /tmp/good.html