Bug with dx/build - how to workaround until fix is up

Hello faithful readers! If you have tried to follow along in the book, you are asked to start up the dev environment via dx/build and are probably getting some issue like

realpath: /Users/davec/Downloads/code/dev-environment/dx/../../dcsidekiq/Book/code/: No such file or directory

I have a fix coming, but to work around this, you’ll need to comment out some lines of code, as in this gist: dx_build.sh · GitHub

What happened was that I had stuff in that script to sync all the code from where I write the book into the Subversion repo where Prag Prog manages the book’s source and sample code. Since you, the reader, don’t have that, it all breaks. My apologies. Please let me know if this works for you!


The code is updated, so if you have downloaded it before today, re-download it and dx/build should be working

Hello, I am trying to run this on Intel Mac, but fake-api-server is only supporting arm architecture Docker, Is it possible to build this image with multiple architecture support?

Error response from daemon: image with reference davetron5000/fake-api-server:1.0.0 was found but does not match the specified platform: wanted linux/amd64, actual: linux/arm64/v8

Dang, I thought I’d made the image multi arch. Will fix tomorrow if I can. In the meantime you could build the image yourself vía dx/build in the fake_api_server sir included with the code and your local Docker should use that image.

Thanks for the hint, missed fake-api-server one folder above.
I managed to build fake-api-server for my architecture, so it is running.
One suggestion, maybe to add instructions to run dx/setup as a first step, so the script updates value for DOCKER_DEFAULT_PLATFORM in docker-compose file, for the ones on intel machines.
Anyway, thank You for the effort on the book.

I just now updated DockerHub with a multi-arch build. The books’ code will be updated to use this, but if you change your docker-compose.dx.yml to reference davetron5000/fake-api-server:1.2.0 that should pull down the proper build based on DOCKER_DEFAULT_PLATFORM

Yes it did solve that but I am having another one(see below) any idea?

$ dx/start
[+] Running 31/3
 ✔ redis 6 layers [⣿⣿⣿⣿⣿⣿]      0B/0B      Pulled                                                                                                          44.9s
 ✔ fake-api-server 10 layers [⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿]      0B/0B      Pulled                                                                                          205.1s
 ✔ db 12 layers [⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿]      0B/0B      Pulled                                                                                                     136.0s
[+] Running 4/5
 ✔ Network sidekiq-book_default              Created                                                                                                        0.1s
 ✔ Container sidekiq-book-redis-1            Created                                                                                                        1.6s
 ✔ Container sidekiq-book-fake-api-server-1  Created                                                                                                        1.6s
 ✔ Container sidekiq-book-db-1               Created                                                                                                        1.6s
 ⠙ Container sidekiq-book-sidekiq-book-1     Creating                                                                                                       0.1s
Error response from daemon: lease "moby-image-sha256:44a1d91fe099be8ff774da77bf8660e37fc7446d6054b858b7ee777a0e9f7e7f": not found

That is super weird. Stack Overflow indicates it’s about using containerd, which is currently experimental. I have it off (since that seems to be the default).

The linked question above says to enable or disable it, but another answer says to delete containers and images then retry. WHen Docker does weird stuff, I have fixed things by nuking a lot of it.

You could try docker container prune, then docker image prune, then starting back at dx/build then dx/start?

Hey David, I’m little confused about the correct code I have to run!
At first, I downloaded the .zip file from the link on the book page at the Pragprog site, so I extracted them and tried to run dx/setup, build and etc. Still, I received a message that the command did not fount (I had to use sudo, because if I ran just dx/setup, I received a message that I don’t have permission), so I stopped to handle with this code.

Looking at this forum I downloaded the code directly from your github, but I saw that in this case, the folders were separated by apps, like sidekiq-book and fake-api-server . So I put the apps in the same directory, I was able to run the dx commands here, but when I run dx/start I received the error:
Error response from daemon: image with reference davetron5000/fake-api-server:1.2.1 was found but does not match the specified platform: wanted linux/amd64, actual: linux/arm64/v8

So, I need to confess that I’m confused about it, I dont know if I using the right code or if I just have missed something, in the book it just says that the code is at the “DIR”. Could help me if I’m using the right code?

I’m using WSL2

I’m not clear on what is happening. Can you start over with the code from the website and paste what you are executing and what you are getting? You should never have to use sudo and you should not be running the apps from the same directory - that will definitely not work properly.

I am on Mac, so perhaps there is an WSL difference, but below is what happens for me. If you see something much different and it doesn’t start up, please paste here what you get. Sorry for the troubles, but we’ll figure it out!

~/Downloads/code/> cd dev-environment
~/Downloads/code/dev-environment> dx/start
[ dx/start ] 🚀 Starting docker-compose.dx.yml
[+] Running 11/11
 ✔ fake-api-server 10 layers [⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿]      0B/0B      Pulled           2.5s 
   ✔ fc9ce7290e7e Already exists                                           0.0s 
   ✔ 73373011d63f Already exists                                           0.0s 
   ✔ 87dafffb02e2 Already exists                                           0.0s 
   ✔ f9cd1c60bb2c Already exists                                           0.0s 
   ✔ 6b219147f22d Already exists                                           0.0s 
   ✔ 1a7ad7cd7388 Already exists                                           0.0s 
   ✔ 498baef37bd3 Already exists                                           0.0s 
   ✔ 64563c4c10f9 Pull complete                                            0.6s 
   ✔ 4f4fb700ef54 Pull complete                                            0.6s 
   ✔ 88788e41478d Pull complete                                            1.6s 
[+] Building 0.0s (0/0)                                                         
[+] Running 4/4
 ✔ Container sidekiq-book-fake-api-server-1  Recreated                     0.3s 
 ✔ Container sidekiq-book-redis-1            Recreated                     0.2s 
 ✔ Container sidekiq-book-db-1               Recreated                     0.3s 
 ✔ Container sidekiq-book-sidekiq-book-1     Recreated                     0.6s 
Attaching to sidekiq-book-db-1, sidekiq-book-fake-api-server-1, sidekiq-book-redis-1, sidekiq-book-sidekiq-book-1
sidekiq-book-db-1               | 2023-10-17T12:34:00.890938000-04:00
sidekiq-book-db-1               | 2023-10-17T12:34:00.891133000-04:00PostgreSQL Database directory appears to contain a database; Skipping initialization
sidekiq-book-db-1               | 2023-10-17T12:34:00.891144000-04:00
sidekiq-book-db-1               | 2023-10-17T12:34:00.936219000-04:002023-10-17 16:34:00.934 UTC [1] LOG:  starting PostgreSQL 15.2 (Debian 15.2-1.pgdg110+1) on aarch64-unknown-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
sidekiq-book-db-1               | 2023-10-17T12:34:00.936249000-04:002023-10-17 16:34:00.935 UTC [1] LOG:  listening on IPv4 address "", port 5432
sidekiq-book-db-1               | 2023-10-17T12:34:00.936263000-04:002023-10-17 16:34:00.935 UTC [1] LOG:  listening on IPv6 address "::", port 5432
sidekiq-book-db-1               | 2023-10-17T12:34:00.954320000-04:002023-10-17 16:34:00.954 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
sidekiq-book-redis-1            | 2023-10-17T12:34:00.963303000-04:001:C 17 Oct 2023 16:34:00.961 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
sidekiq-book-redis-1            | 2023-10-17T12:34:00.963334000-04:001:C 17 Oct 2023 16:34:00.961 # Redis version=6.2.13, bits=64, commit=00000000, modified=0, pid=1, just started
sidekiq-book-redis-1            | 2023-10-17T12:34:00.963340000-04:001:C 17 Oct 2023 16:34:00.961 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
sidekiq-book-redis-1            | 2023-10-17T12:34:00.963344000-04:001:M 17 Oct 2023 16:34:00.962 * monotonic clock: POSIX clock_gettime
sidekiq-book-redis-1            | 2023-10-17T12:34:00.963349000-04:001:M 17 Oct 2023 16:34:00.962 * Running mode=standalone, port=6379.
sidekiq-book-redis-1            | 2023-10-17T12:34:00.963352000-04:001:M 17 Oct 2023 16:34:00.962 # Server initialized
sidekiq-book-redis-1            | 2023-10-17T12:34:00.967224000-04:001:M 17 Oct 2023 16:34:00.965 * Loading RDB produced by version 6.2.13
sidekiq-book-redis-1            | 2023-10-17T12:34:00.967249000-04:001:M 17 Oct 2023 16:34:00.965 * RDB age 1810727 seconds
sidekiq-book-redis-1            | 2023-10-17T12:34:00.967260000-04:001:M 17 Oct 2023 16:34:00.965 * RDB memory usage when created 0.81 Mb
sidekiq-book-redis-1            | 2023-10-17T12:34:00.967269000-04:001:M 17 Oct 2023 16:34:00.965 # Done loading RDB, keys loaded: 1, keys expired: 0.
sidekiq-book-redis-1            | 2023-10-17T12:34:00.967274000-04:001:M 17 Oct 2023 16:34:00.965 * DB loaded from disk: 0.001 seconds
sidekiq-book-redis-1            | 2023-10-17T12:34:00.967277000-04:001:M 17 Oct 2023 16:34:00.965 * Ready to accept connections
sidekiq-book-db-1               | 2023-10-17T12:34:00.969714000-04:002023-10-17 16:34:00.970 UTC [29] LOG:  database system was shut down at 2023-09-26 17:35:13 UTC
sidekiq-book-db-1               | 2023-10-17T12:34:00.992078000-04:002023-10-17 16:34:00.991 UTC [1] LOG:  database system is ready to accept connections
sidekiq-book-fake-api-server-1  | 2023-10-17T12:34:01.526997000-04:00== Sinatra (v3.0.6) has taken the stage on 4000 for development with backup from Puma
sidekiq-book-fake-api-server-1  | 2023-10-17T12:34:01.527024000-04:00Puma starting in single mode...
sidekiq-book-fake-api-server-1  | 2023-10-17T12:34:01.527034000-04:00* Puma version: 6.2.2 (ruby 3.2.2-p53) ("Speaking of Now")
sidekiq-book-fake-api-server-1  | 2023-10-17T12:34:01.527039000-04:00*  Min threads: 0
sidekiq-book-fake-api-server-1  | 2023-10-17T12:34:01.527043000-04:00*  Max threads: 5
sidekiq-book-fake-api-server-1  | 2023-10-17T12:34:01.527046000-04:00*  Environment: development
sidekiq-book-fake-api-server-1  | 2023-10-17T12:34:01.527053000-04:00*          PID: 8
sidekiq-book-fake-api-server-1  | 2023-10-17T12:34:01.527183000-04:00* Listening on
sidekiq-book-fake-api-server-1  | 2023-10-17T12:34:01.528356000-04:00Use Ctrl-C to stop
sidekiq-book-sidekiq-book-1     | 2023-10-17T12:34:03.235099000-04:00
sidekiq-book-sidekiq-book-1     | 2023-10-17T12:34:03.235133000-04:00
sidekiq-book-sidekiq-book-1     | 2023-10-17T12:34:03.235139000-04:00
sidekiq-book-sidekiq-book-1     | 2023-10-17T12:34:03.235144000-04:00 🎉  Dev Environment Initialized! 🎉
sidekiq-book-sidekiq-book-1     | 2023-10-17T12:34:03.235155000-04:00
sidekiq-book-sidekiq-book-1     | 2023-10-17T12:34:03.235166000-04:00 ℹ️   To use this environment, open a new terminal and run
sidekiq-book-sidekiq-book-1     | 2023-10-17T12:34:03.235173000-04:00
sidekiq-book-sidekiq-book-1     | 2023-10-17T12:34:03.235176000-04:00     dx/exec bash
sidekiq-book-sidekiq-book-1     | 2023-10-17T12:34:03.235181000-04:00
sidekiq-book-sidekiq-book-1     | 2023-10-17T12:34:03.235189000-04:00 🕹  Use `ctrl-c` to exit.
sidekiq-book-sidekiq-book-1     | 2023-10-17T12:34:03.235193000-04:00
sidekiq-book-sidekiq-book-1     | 2023-10-17T12:34:03.235195000-04:00
sidekiq-book-sidekiq-book-1     | 2023-10-17T12:34:03.235203000-04:00

Hey David, thanks for your reply!
I downloaded the code again, extracted the files, accessed the dev-environment, and run dx/build, so I received the error as you can see in the image below:

I’ll try run this on Ubuntu, maybe it’s a WSL issue :slightly_frowning_face:

Can you try doing chmod +x dx/* and try it again? I wonder if windows is not preserving the executable bits on those scripts?

Also, what are those Zone.Identifier files? They were not part of the .zip file.

1 Like

Hey David, it worked after applying chmod, so probably is something correlated with WSL/Windows permission, but during the application build, I received this error about the image, when I run the dx/setup, I set the arch with linux/amd64 but for some reason the docker is trying to use linux/amd64/v8.

Is it something that you saw before?

[ dx/start ] 🚀 Starting docker-compose.dx.yml
[+] Running 1/0
 ✔ Network sidekiq-book_default              Created                                       0.1s
 ⠋ Container sidekiq-book-fake-api-server-1  Creating                                      0.0s
 ⠋ Container sidekiq-book-db-1               Creating                                      0.0s
 ⠋ Container sidekiq-book-redis-1            Creating                                      0.0s
Error response from daemon: image with reference redis:6 was found but does not match the specified platform: wanted linux/arm64/v8, actual: linux/amd64

About the Zone.Identifier I don’t know too, but I saw this article that talks about, it’s WSL stuff… when a file is moved from Windows to WSL, but I think it won’t be a problem.

OK, weird. It’s saying it’s trying to find an ARM version of Redis - Redis publishes multi-platform builds and, in theory, Docker should be pulling the correct one for your platform.

First, see if it somehow pulled the wrong one and wont’ fix it by deleting anything you have already:

  1. docker image ls redis
  2. If you see any redis 6 in there, do a docker image rm «image id» using the value from the IMAGE ID column shown in docker image ls
  3. If you get “image is referenced in multiple repositories” error, you’ll need to do docker image rm redis/«tag» where «tag» is the value from the TAG column. Docker can be super annoying sometimes

Then, try it all again.

If this still happens, you can force Docker to use your platform by setting this in your shell:

export DOCKER_DEFAULT_PLATFORM=linux/amd64

This env var should force Docker to use the right one.

Sorry about all this - I thought WSL was truly unix, but I guess not :frowning:

Thanks David!
I tried this and it works, but after, the same error happened with postgres image, I repeated the step for postgres and now I received this error :melting_face:

[ dx/start ] 🚀 Starting docker-compose.dx.yml
[+] Running 3/0
 ✔ Container sidekiq-book-fake-api-server-1  Recreated                                                                                                 0.1s
 ✔ Container sidekiq-book-db-1               Recreated                                                                                                 0.1s
 ✔ Container sidekiq-book-redis-1            Recreated                                                                                                 0.1s
 ⠋ Container sidekiq-book-sidekiq-book-1     Creating                                                                                                  0.0s
Error response from daemon: lease "moby-image-sha256:3eac2e0750058ad102fed274ba9ea4b94cba60a31c620205a42dec98daa81661": not found

It seem that correlated with this situation

Have you ever saw this before?

I have seen that once, and I had to remove all of my images and retry everything with docker system prune.

This GitHub issue indicates it could be masking another version of the “wrong platform” issue you had earlier.

Since the output looks like it’s happening on the dev container for working on the book, I wonder if before doing docker system prune you could try docker image rm any image related to the sidekiq-book image/container, then try rebuilding that one with dx/build? Perhaps after setting that env var (perhaps for whatever reason the first time it build the wrong platform?)

Greetings Dave & other readers,

I encountered an error running dx/build:

The command ‘/bin/sh -c sh -c ‘echo “deb Index of /pub/repos/apt/ $(lsb_release -cs)-pgdg main” > /etc/apt/sources.list.d/pgdg.list’ && wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - && apt-get update && apt-get -y install postgresql-client-15’ returned a non-zero code: 100

At first, I tracked this down to an August announcement.

But other lines in the build were pointing to bookworm rather than buster.

I’m not sure why $(lsb_release -cs) wasn’t getting set properly rather than investigate I just subsituted in the inferred release.

It required the following change to Dockerfile.dx (line 38):

`RUN sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'  && \`

Change to:

`RUN sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt bookworm-pgdg main" > /etc/apt/sources.list.d/pgdg.list'  && \`

For some reason, docker was also requesting the wrong platform my my cpu (archlinux with amd64). I resolved this by specifying the platform in docker-compose.yml:
platform: linux/amd64


I have noticed few issue I am on my Arm machine, but you don’t have code repo so I can put suggestions.

first issue: Dockerfile.dx require lsb-release installation, so you can do by adding in end of line 23.

    apt-get install -qy rsync lsb-release

Another issue is book does not mention about configuration sidekiq so it can connect with redis:5739 so by default sidekiq try to connect local environemnt when you start sidekiq web gui. So you can add a new file config/initializer/sidekiq.yml with following content

sidekiq_config = { url: ENV['SIDEKIQ_REDIS_URL'] }

Sidekiq.configure_server do |config|
  config.redis = sidekiq_config

Sidekiq.configure_client do |config|
  config.redis = sidekiq_config

Still started reading will update more issue came.

The book example app uses dotenv which sets the URL correctly. This is covered on pages 4 and 5 during the initial setup.

The missing lsb-release is an issue and I think a point release of Debian must’ve removed it.

1 Like

OK the repo has been updated so that lsb-release is installed. I have no idea why Debian removed it :frowning:

1 Like