Docker linked container problems

I need a postgres container linked to a rails container. The rails container needs to install SpreeCommerce, but not before pointing to the postgres container for the database connection.

Using docker-compose to orchestrate these things leads to a common problem. All of the containers launch concurrently, and the rails container attempts the Spree Commerce installation before the postgres server is actually listening for connections.

Let it be known I am holding back from venting about the dichotomy between Docker’s amazing ability to simplify the development/deployment process, and Docker’s grand reluctance to implement even a basic ready-state for containers (instead insisting on multi-step implementation of ready-state scripts). Docker has their reasons, but google the issue and you’ll see this is a sorely needed functionality. Whoops, I just vented.

This post aims to create more of a ‘lay tutorial’ for linking containers. I explore the method of using a shell script (on container1) that waits and listens for a postgres server (on container2) to become ready, after which container1 can install Spree Commerce (as spree initially populates its database).

Docker recommends using a docker-compose entrypoint, and a CMD (in the dockerfile) to be completed after says the database is ready.

Using the example from Docker’s recommendation. The docker-compose file looks like this:


version: “2”
build: .
– “80:8000”
– “db”
entrypoint: ./ db:5432
image: postgres

docker-compose.yml has two services (actions), and thus builds two images. Whenever you want to use those images, they create separate entities called containers.

build: .
#builds the web image using the dockerfile located in the directory you run the “docker-compose build .” command from. This directory is alternatively called the ‘current context’. Note that those dockerfile instructions are not shown in this post.

– “8000:80”
#expose ports to the host as HOST:CONTAINER. That is, container port 8000 is routed to host port 80. For example, if you are running a webserver in your container that is expecting traffic from port 8000, you can communicate with it from the computer running docker via your-docker-host-ip:80. Note that if you try to expose ports via your dockerfile (not covered here), those ports are only available to other containers within your virtual docker network. For example, using EXPOSE 8000 in your dockerfile would allow outgoing traffic from other containers (whatever port they choose) to be sent to port 80 on the container you EXPOSED.

– “db”
#some newcomers may be tempted to think that the web image is somehow being built from db. That is not true here. The depends_on key instead means the Web container will not run without the companionship of the DB container (example: if you were to use docker-compose to build these two images, create their respective containers, manually delete the db container, you would not be able to launch the web container).

entrypoint: ./ db:5432
#First off, is a github project by vishnubob–big thanks to him (and his employer Ginkgo Bioworks). In a nutshell, this instruction looks for Work-dir-set-by-dockerfile/ located in the Web image. That is, in the dockerfile you can set a work directory (such as /usr/home/scripts/) and that will become the relative path used whenever you don’t explicitly specify an absolute path. The arguments passed to the script (db:5432) tell the script to repeatedly check the linked container db for a port 5432 response.

image: postgres
#This is analogous to the “build: .” key used above in Web. Instead of looking to the dockerfile for image build instructions, this points docker to use an image that already exists (docker looks locally for the existence of a “postgres” image, and if not found, looks on the official docker repository).

Create a launcher for Sublime Text which always opens a new window (in Windows)

The default behavior of the Sublime Text 3 launcher in Windows is to show any currently open Sublime Text windows. This really shouldn’t be the default behavior, but what-evs.

My quickfix: create a new batch file named sublime-launcher.bat with the following contents:
start “C:/Program Files/Sublime Text 3/sublime_text.exe” “–new-window”

For whatever reason, I’m not able to pin this to my start bar in Windows 10. Tired of these things–so as soon as I get the time I’ll be swapping my primary installation over to some flavor of linux.

Adding a google font to a wordpress theme (via child theme)

Anatomy: Background // What you came here for // Conclusion

Since I’ve gone freelance, a number of jobs I’ve done are WordPress updates, repairs, and migrations.

It’s been a challenge and forced me to rework my general approach to technical troubleshooting to save time. I have a locust of problems experienced locusting through my poor head right now from the site I’m currently working on, and situations worth mentioning from past sites. Do I fix these problems the right way, or blindly toss a patch in for the next poor soul 3 years later? I try to do it the right way–I’ll slowly get fast at all the right ways.

The site I’m currently working on is for a big-time music video producer–its theme hasn’t been updated in 3 years, and lives somewhat inharmoniously with an almost-up-to-date WordPress core. It’s slow, and barely responsive (to screens/mobile).

What you came here for:

The client wants this Google Font:

  1. I tried the quick and wrong way first so I could instead work on more important problems. Keyword: tried.

    In /wp-content/themes/aware/header.php towards the top of <head></head> section, insert the code <link href=”” rel=”stylesheet”>

    It is safer to do it towards the top of the head section, ensuring you don’t accidentally place the font-import after the CSS import which calls for the font. That is it say, you want this order of events: (1) Import font, (2) Import CSS file that says, “use this font.”

    Calling for google font above any other style sheets.
    Notice the stylesheet is called immediately after, and definitely outside of any php tags (though you could have it inside of php tags if you echo the <script> statement).

    I then modified /wp-content/themes/aware/styles.css. I searched for font-family in that file and added ‘Poiret One’ and an !important tag. That is: font-family: ‘Poiret One’, Arial, Helvetica, sans-serif !important;

    add the new google font as the first font to use
    Unashamed use of !important.

    But it didn’t work and I didn’t delve into why.

  2. With some quick google-fu, I found some tips on adding the font to this theme the correct way. Update with that in progress.