Dive into Docker takes you from "What is Docker?" to confidently applying Docker to your own projects. It's packed with best practices and examples. Start Learning Docker →
We'll go over running a few docker-compose.yml files at once, even with custom file names. We'll also use the COMPOSE_FILE env variable.
I recorded every step of the way when updating a bunch of packages and services. From the idea to tweeting out the end result.
Here's a few patterns I've picked up based on using Docker since 2014. I've extracted these from doing a bunch of freelance work.
In this video we'll go over an example of how writing shell scripts can help save you a lot of time for things you do regularly.
We'll go over how to regain lots of disk space by compacting the VM file that Docker Desktop creates. I ended up getting 50gb back.
This Vim plugin lets you run one test, a full file or all of your tests for 20+ programming languages and test runners.
This is specific to using Docker Compose on a single server deploy. Here's how I arrived at this choice after years of experimenting.
In this video, we'll go over both the why and how to set up a number of web app servers to log to stdout.
In this video, we'll go over all of the tools I use on Windows and WSL 2 to create a productive development environment.
In this video, we'll go over using a script to make sure your database is ready before running automated tests. Perfect for CI.
There's a number of ways for files to lose certain permission bits in transit, such as unzipping it with certain unzip uilities.
In this video we'll cover how to use the same gunicorn config file in dev and prod but still be able to tweak settings with env variables.
An override file lets you use the same Docker Compose file in development and production while being able to run different services.
A 1 hour live demo that uses various git commands, Travis-CI and GitHub features to fix a bug and push a new release.
There's pretty big benefits for having your health check defined in your Docker Compose file instead of your Dockerfile. Here's why.
In this video we'll go over how to use nginx with Docker to serve a local Jekyll site so that you can test your audio player.
In this short video we'll go over how to list all Docker tags for a specific image on the Docker Hub using the command line.
Follow along in this 30 minute video where we encounter and fix a bunch of errors while upgrading Python 2.7.16 to Python 3.7.4.
I had to parse 400mb of XML for some client work and I tried a few different strategies. Here's what I ended up with.
If you're getting errors that you can't explain or you're getting different types of errors with the same code you might be out of memory.
Docker makes it easy to stop containers by a specific container name, but here's how you can stop containers by a wild card pattern.
It currently supports Phoenix, Rails, Django and Laravel, and this is a 30 minute video demoing how it works and how it was built.
YAML anchors let you reuse parts of your YAML file like functions. You can use them to share default settings between services.
If you're looking for an image or its tags from the Docker Hub, you can search and filter them using the Docker CLI tool.
You can run multiple containers in the background and then wait until they all finish before moving on with your script.
Every once in a while you may want to create a pre-built PostgreSQL Docker image that already has a database.
Docker Compose's Compatibility mode may help you use certain API v2 properties inside of an API v3 Docker Compose file.
Installing Docker on Debian is normally a straight forward task, but if you want to use the unstable release you need to make a change.
So, you're thinking about deploying a Docker Compose project, but where does the docker-compose.yml file go on your file system?
Volume mounts are great in development, but it's usually not great when you end up with node_modules on your Docker host.
On Linux, Docker Compose doesn't come bundled up with Docker like it does on Docker for Windows / Mac. So which one should you use?
Most of the time we connect to Docker running on our local machine, but you can also connect to Docker on a different machine too.
I've spent a full year using WSL and I am still convinced it is the ultimate development environment set up if you use Windows.
Docker works great most of the time, but when it comes to Docker for Windows, a few things can cause your apps to stop working.
Running tests locally or inside a continuous integration server share the same workflow. This is one reason why Docker is so useful.
You can't just load up your hypervisor's management app and log into the VM that Docker created, but you can check it out. Here's how.
By default, Docker's container log files will consume your entire disk unless you tell it not to. Here's how to cap log disk space.
Docker makes it easy to run applications in a unified way, but when it comes to static sites, I typically don't run them in Docker.
Using Docker to pull a public image should not require authentication but if your Docker Hub login credentials are bad it will fail.
In this case it was a Docker command that was throwing an error, but I would have applied this process to any problem.
This error could happen for a few reasons, but here's one fix to it that can be done by renaming a folder in your volume's path.
Once in a while you may need your Docker host's IP address. Here's how to do it on Docker for Mac, Windows and Linux.
Sometimes you'll get weird errors from Docker or your application but you're sure things are set up right. Here's what you can do.
The official terms for this are exec form and shell form commands. Both do nearly the same thing, but there's an important difference.
Most official Docker images offer both Debian and Alpine based images but there's some surprising performance results between the 2.
This use case comes up often if you work on a project where you need a separate Dockerfile for your back-end and front-end.
Phoenix 1.4 is set to use Webpack but Phoenix 1.3 currently uses Brunch. Here's how to get Webpack working with Phoenix 1.3.
Create, start and run all sound pretty similar but they each have their own distinct roles. Here's what each of them do.
You can use this method with any package manager that has the concept of a lock file to help with dependency management.
In this tip you'll learn how to look under the hood of what Docker Compose is doing whenever you run any of its commands.
Here's a few patterns and little things I've picked up after using Docker since 2014. These help maintain Docker driven apps.
You can expose ports by using EXPOSE in your Dockerfile, --expose on the command line but there's also publishing ports too.
This isn't really a Docker tip because you can do the same thing on any Linux based OS but it's useful nonetheless.
You can build an image from a Dockerfile, and you can pull an image from a Docker Registry, but what happens when you supply both?
On paper this sounds easy. Just mount in your SSH directory and you're done, but it's not that simple with Windows based Docker hosts.
You may want to enable read-only on your containers to enhance its security, or perhaps you have other app specific needs.
You may get this error when trying to access a web server running in a container. Empty reply from server is another common error.
A Docker repository is where you can store 1 or more versions of a specific Docker image. An image can have 1 or more versions (tags).
Container and image IDs are 64 character SHA-256 IDs. Most Docker commands truncate them to 12 characters, but you only need 4 chars.
Docker Compose has 3 major API versions (v1, v2 and v3). Certain features are enabled / disabled depending on which one you use.
Running an insecure registry isn't recommended but sometimes it's the easiest and most reasonable solution. Here's how to do it.
When dealing with databases such as PostgreSQL, MariaDB or MySQL, you've likely wanted to import a raw SQL file. Here's how.
So, you've been making changes inside of a container and now you want to see how it differs from the original. Here's how.
Docker allows you to set both build time and run time ENV variables and even lets you overwrite build time ENV vars at run time.
If you find yourself frequently changing directories in your Dockerfile then you may want to look into using WORKDIR. Here's how.
You can stop your containers using the stop or down command, but the down command does more than stopping your containers.
Here's a simple command to show you much disk space is being taken up by Docker images, containers, volumes and build cache.
Docker Compose supports ENV variable substitution and overriding YML files. The config command lets you see the true values being run.
Part of being a developer includes setting up your computer so that you can develop the applications you want to write.
Docker is great at isolating processes, and they can either be long running processes (like a web server), or tasks that exit quickly.
Before Docker, it was common to use Virtualenv, RVM and other runtime versioning tools. Do we need them inside of Docker images?
Docker gives us a way to isolate processes but when it comes to cron jobs, let's run them on the Docker host when possible.
Docker CE is not officially supported on RHEL but if you're in a pinch, you can get the latest Docker CE installed on it.
You may have gotten cryptic errors when trying to use ENTRYPOINT scripts in your images while running Windows. Here's how to fix them.
There may come a time where you accidentally share your Docker login token for the Docker Hub. Changing your password will revoke it.
Docker is a few years old now, and if you're dealing with older Docker projects, you may run into links. Here's what it is.
Someone recently asked me to define DevOps. This is one of those terms where everyone has a slightly different definition.
RUN lets you run commands but CMD also lets you run a command, so which one should you use, and when?
Once in a while you may want to connect a container to a database or service running on your Docker host. Here's how to do it.
It's finally time to deploy your app to production. There's a few Docker related tools to choose from, but will Compose work?
Both tools allow you to manage a cluster of servers that run 1 or more services on them. Let's go over both.
For passing in a host's folder into a container both flags do basically the same thing. So which one should you use?
Learn how to automatically remove dangling Docker images and other resources on a daily basis for Linux, Windows and MacOS.
If you're working with Docker, you've probably noticed a lot of none references when you list your images. Here's how to clean them up.
In this article you'll see how to run a PDP-11 simulator through Docker to interact with Unix as it was back in 1972.
Once in a while you may want to execute Docker Compose commands from somewhere other than your project's directory. Here's how.
There's a few reasons why a container might fail to access the internet but we're going to talk about iptables in production here.
Socrates left behind a way to deeply explore a topic in a systematic way. It's called Socratic questioning. Let's apply it to Docker.
There's a couple of ways to save and sync data between a container and your Docker host. Let's compare 2 of them.
Just about every web app I develop uses Redis and being able to easily set a password on it is useful. Here's how you do it.
Docker related aliases and functions can save you a lot of typing in the long run. Here's how to set up my favorite ones.
With a couple of tweaks the WSL (Windows Subsystem for Linux, also known as Bash for Windows) can be used with Docker for Windows.
Labels allow you to do pretty interesting things with your Docker images. Here's a few basic use cases.
Docker 1.13+ introduced grouped commands to help organize a bunch of Docker commands. Both commands do the same thing.
Docker Compose and Docker Stack can both be controlled by a docker-compose.yml file. Learn the differences between them.
Learn the differences between Docker 1.13 and the current version's format along with CE / EE and the stable vs edge channels.
Once in a while, you may want to check the exact exit code of a stopped container. Here's how to do it.
Docker has a built in command to let you see how much CPU, memory, network I/O and block I/O your containers are using.
Being able to access the Docker daemon as a non-root user is a quality of life enhancement. Here's how to do it on Linux.
Here's how to ignore certain files and folders from your Docker images. This lets you copy in everything you want, while ignoring the cruft.
Learn how to get syntax highlighting and more with Docker related files for Sublime Text 3, VSCode, Atom, Emacs and Vim.
Pinning your versions only takes a few extra seconds but I promise you, it's going to save you a ton of time in the future. Here's why.
Breaking up long lines in your Dockerfile will make your Dockerfile much easier to skim and read. Here's how to do it.
Every once in a while I find the need to dump a container's file onto my Docker host. Here's one way to do that very easily.
Being able to identify what something is can lead to learning complex topics faster. Here's how these 3 Docker concepts tie together.
Did you know Docker acts as a firewall for your Dockerized services? You can enable or disable your services from listening on a port too.
You can transition into using Docker without trying to solve every scalability problem in the world at once. Just ease into it.
Docker for Windows uses Hyper-V. Having Hyper-V installed prevents you from running VirtualBox or VMWare VMs. Here's a workaround.
As developers and sysadmins, we know the wins of using Docker, but how do you explain the benefits of using Docker to business people?
If you're creating apps written in dynamic languages such as Ruby, Python or Node then you should be using volumes in development.
If you're running macOS or Windows you have a few options for installing Docker. There's even a third way too, and we'll compare them here.
When tinkering with Docker as a beginner it's really easy to drown from information overload. Here's a life jacket.
I'm sure at some point you'll want to install Docker and Docker Compose on your production server, and Ansible makes it easy.
When it comes to organizing your larger projects with Docker and Docker Compose there are a number of options. Here's how I do it.
Trying to take in Docker from ground 0 can be overwhelming. This article explains the purpose of 10 different Docker tools and services.
Alpine is a lightweight Linux distribution. Learn how to install a few packages that are commonly found in web applications.
If you want to shrink your Docker images, have your services start faster and be more secure then try Alpine out.
If you've built any type of real world web app, chances are you've wanted to run different services from the same Docker image. Here's how.
I'm a very pragmatic developer and only jump ship to new technologies when I see a big benefit. Here's what drove me to use Docker.
RUN and CMD are very important pieces to a Dockerfile and they both perform much different tasks. Here's what they do.
Docker puts you into a great position to manage the full life cycle of your applications, which could naturally lead to being a sys admin.
With a little bit of elbow grease you can get Docker running on your Chromebook, which can be a very affordable and portable dev machine.
If you're new to Docker, it can be difficult to see the benefits of build, ship and run any app, anywhere. So, let's talk about it here.
Docker will happily build your images if they have a different OS, but you can get a few quick wins by using the same base OS all around.
There is some overlap on what each of these tools can do for you, but at the end of the day it makes a lot of sense to use both together.
Your Docker Image OS is what you have defined in your Dockerfile and your host OS is what you're running Docker on. They can be different.
Docker is not a monolithic piece of software. It is composed of a few different tools and this article will cover the daemon and the CLI.
You might be doing things in your Dockerfile that are causing your images to be bloated. Here's 1 strategy for shrinking them.
You've done your research and decided that you're going to embrace Docker, but how do you begin the migration process?
Sometimes you see COPY or ADD being used in a Dockerfile, but 99% of the time you should be using COPY, here's why.
Visualize and understand the difference between how applications run in both Virtual Machines and Docker Containers.
There's a number of ways to better understand what Docker containers are, and one way to do that is to define what Docker containers aren't.
When you don't need to worry about how to install something, it really opens the door to letting you pick whatever technology fits best.
Moby Project is to Docker as Electron is to VSCode and Atom. Both are frameworks that let you build completely different products.
Docker will easily let you run multiple versions of your favorite programming language. Eliminate tools like rvm, virtualenv, nvm and phpbrew.
How DNS may cause temporary errors when trying to register an SSL certificate with Let's Encrypt, or anything really.
Every once in a while a Unicorn technology or framework is born and turns the industry upside down. Docker is a Unicorn in the making.
Learn how to install and use Docker to run a Rails 5, Postgres, Redis, Sidekiq and Action Cable app in development with Docker Compose.
Learn how to install and use Docker to run a multi-service Flask, Celery and Redis application in development with Docker Compose.
Understand the problems Docker solve and how it will potentially save you years of headaches by following a time-line of a fictional developer.
We all know that Alpine based Docker images are smaller, but how much does it matter for non-trivial applications that need libraries compiled?
Join me on Kickstarter to gain a discount on my upcoming course which will teach you all about Docker.
Rescue yourself from the complexity of DevOps with this guide book on Docker. A 55 page book for less than the cost of a pizza.
Like you, I'm super protective of my inbox, so don't worry about getting spammed. You can expect a few emails per month (at most), and you can 1-click unsubscribe at any time. See what else you'll get too.