Search results

/postroll

Changing port maps in Docker Compose

akrabat.com

Rob details how to override and remove values in a Docker compose file when using a compose.override.yml or extending a value/service.

To just override it:

- ports: !override
  - "8081:80"

This is necessary, as otherwise if the value is already present in the original, the two settings get merged.

To remove:

- ports: !reset []

From the blog

Do you know the preferred Docker compose file name?

I've been using Docker for... a long time now. So having a docker-compose.yml file in a project is pretty natural and common for me.

Today I learned that the preferred file is now compose.yaml (though compose.yml is also allowed), and that the docker-compose naming is only supported for backwards compatibility. (See the Compose file documentation if you don't believe me!)

Funny enough, the compose tooling doesn't call this out, even though it now calls out the fact you don't need to use the version setting any more.

/postroll

Prevent the Docker container from taking 10 seconds to stop

akrabat.com

Rob Allen details how the exec form of a Docker CMD is the better form to use. The reason the string form invokes bash first, and thus bash gets PID 1, which is what Docker will terminate when the container is terminated. The problem is that bash doesn't then send a termination signal to the actual process invoked, forcing the Docker host to wait 10 seconds before force killing all processes in the container.

From the blog

Copy A File From A Docker Container to the Host

Occasionally, I want to get a file from a Docker container back to the host system.

First, you need to get the container ID; you can do this using docker ps. Once you have that, use, docker cp as follows:

docker cp <containerId>:/path/to/file/in/container path/on/host

From the blog

Fixing Redis background-save issues on Docker

I've been running redis in Docker for a number of sites, to perform things such as storing session data, hubot settings, and more.

I recently ran into a problem on one of my systems where it was reporting:

Can't save in background: fork: Out of memory

From the blog

Building a usable ext-tidy for Alpine-based PHP Docker images

I've been working on building PHP Docker images for the purposes of testing, as well as to potentially provide images containing the Swoole extension. This is generally straight-forward, as the official PHP images are well-documented.

This week, I decided to see if I could build Alpine-based images, as they can greatly reduce the final image size. And I ran into a problem.

Search tips

  • Use #{some tag} or tag:{some tag} to filter by tag; using this more than once will find results that match all tags.
  • Use year:{year} to filter by year. If you use this multiple times, the last one wins.
  • Use begin:{year-month-day} to restrict to results beginning on that day. Last one wins.
  • Use end:{year-month-day} to restrict to results ending on that day. Last one wins.