evilmartians / ruby-on-whales

Ruby on Whales example and templates
MIT License
295 stars 26 forks source link

The `CMD` command contains an invalid value #24

Closed vill closed 10 months ago

vill commented 11 months ago

https://github.com/evilmartians/ruby-on-whales/blob/b8c47dbee5ab46bb5e891fdb9b0f947f12d4ceed/example/.dockerdev/Dockerfile#L83

ls -lh /usr/bin/bash
ls: cannot access '/usr/bin/bash': No such file or directory

The correct value should be:

which bash
/bin/bash
palkan commented 11 months ago

Can you please tell your build args, such as RUBY_VERSION and DISTRO?

vill commented 11 months ago
# compose.yaml
RUBY_VERSION: '3.2.2'
# Dockerfile
ARG RUBY_VERSION
ARG DISTRO_NAME=bullseye

FROM ruby:$RUBY_VERSION-slim-$DISTRO_NAME
palkan commented 11 months ago

Thanks! And when do you this error, how to build the image? I've haven't seen this problem in any project (all based on this Dockerfile and having the same CMD line).

vill commented 11 months ago

I executed these commands inside the created container:

ls -lh /usr/bin/bash
ls: cannot access '/usr/bin/bash': No such file or directory

which bash
/bin/bash

I've haven't seen this problem in any project (all based on this Dockerfile and having the same CMD line).

You won't have any problems even if you specify this value for CMD

CMD ["/usr/bin/abracadabra"]

Perhaps the problem can be seen if you run this through docker and not compose.

vill commented 11 months ago

CMD is redefined for example here: https://github.com/evilmartians/ruby-on-whales/blob/b8c47dbee5ab46bb5e891fdb9b0f947f12d4ceed/example/.dockerdev/compose.yml#L53

vill commented 11 months ago

Why then is/bin/bash used here and not/usr/bin/bash?

https://github.com/evilmartians/ruby-on-whales/blob/b8c47dbee5ab46bb5e891fdb9b0f947f12d4ceed/example/dip.yml#L16-L19

palkan commented 10 months ago

CMD is redefined for example here

oh, I see; thanks for the explanation; yeah, we always use compose locally.

Why then is /bin/bash used here and not /usr/bin/bash?

Wish I knew 😄 I guess it was added originally to not depend on CMD (in case it has been redefined) and make this command always work.