Skip to content

Commit fdf183a

Browse files
committed
new entry
1 parent 6245e00 commit fdf183a

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
title: Debugging Docker Production Builds
3+
date: 2022-06-29
4+
desc: A quick reference on how to browse the contents of a production docker image
5+
img: /img/2021/barrett-ward-5WQJ_ejZ7y8-unsplash.jpg
6+
tags:
7+
- docker
8+
---
9+
10+
![Shipping containers in a busy port](/img/2021/barrett-ward-5WQJ_ejZ7y8-unsplash.jpg)
11+
12+
Photo by <a href="https://unsplash.com/@barrettward?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Barrett Ward</a> on <a href="https://unsplash.com/s/photos/container?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Unsplash</a>{class="photo-byline"}
13+
14+
Filing this one under things that I'm writing for my future self to reference.
15+
16+
Who among us hasn't had the experience where you're getting a bug report for a bug that you know you fixed, and it seems like your fix is just being ignored in production? (If you haven't had that experience, I envy you!)
17+
18+
This is especially frustrating when your production environment is a Docker container running in the cloud, built by a CI/CD server. You can't exactly SSH into the server and look at the code to make sure your deploy _actually worked_. I guess you could unblock that, but it seems like the wrong reason to open up SSH ports on your production containers and probably inadvisable.
19+
20+
Anyway, if you find yourself in this situation, here's how you can double-check what's actually inside that production container. My notes are from Amazon's AWS Elastic Container Repository (ECR) but the steps should be the same even if you're using a different service and the syntax varies.
21+
22+
1. Log in to ECR:
23+
24+
```bash
25+
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin <account-id>.dkr.ecr.us-east-1.amazonaws.com
26+
```
27+
28+
2. Pull the image from ECR to your local machine:
29+
30+
```bash
31+
docker pull <account-id>.dkr.ecr.us-east-1.amazonaws.com/my/repo/name:tagname
32+
```
33+
34+
3. Start the container locally:
35+
36+
```bash
37+
docker run -it --entrypoint /bin/bash <account-id>.dkr.ecr.us-east-1.amazonaws.com/my/repo/name:tagname
38+
```
39+
40+
This starts the container in interactive mode and rather than launching its usual startup command, runs, in this case, `/bin/bash` to give you a shell to browse around the container.
41+
42+
Now you can dig around and make sure your code changes are in fact represented in the production build, where and how you expected.
43+
44+
What should you do if the code is what you wanted it to be and the app still doesn't work?
45+
46+
Well, friend... That remains one of life's great mysteries.

0 commit comments

Comments
 (0)