rails/docked

Bug: cannot run multiple consoles via docked rails c

alexspark opened this issue · 5 comments

Given I already have a live console via docked rails c, I cannot start an additional rails console with docked rails c.

The error I receive is:

docker: Error response from daemon: driver failed programming external connectivity on endpoint vigorous_hertz (be93a27e17aba8081f1a9cb781f7a6f38b7fa1e6f8535fa3f474a1d9eed39b99): Bind for 0.0.0.0:3000 failed: port is already allocated.

You are having that problem because the docked alias is using port 3000. You should be able to open multiple consoles using the command without specifying a port:
docker run --rm -it -v ${PWD}:/rails -v ruby-bundle-cache:/bundle ghcr.io/rails/cli rails console
In addition, you could add this alias to avoid the command above:
alias rails-console='docker run --rm -it -v ${PWD}:/rails -v ruby-bundle-cache:/bundle ghcr.io/rails/cli rails console'

ah that makes sense!

perhaps the README suggestion for the docked alias should not include -p 3000:3000 since it is only really useful for server and bin/dev CLI commands.

dhh commented

Why do you need to run multiple consoles?

I have multiple consoles running b/c I'm debugging different things in the application. It helps to have the related history of commands within a single console.

pjar commented

Another option would be to get into running container. I start with docked rails server, then I get list of running containers docker ps to find name of the running container and by docker exec -it <container_name> rails c. You can do it in as many terminals as needed.