I have a line that looks something like:
RUN for i in `x y z`; do echo "$i"; done
...with the intention of printing each of the three items
But it raises /bin/sh: 1: x: not found
Any idea what I'm doing wrong?
The docker run command first creates a writeable container layer over the specified image, and then starts it using the specified command. That is, docker run is equivalent to the API /containers/create then /containers/(id)/start .
Apart from the Dockerfile CMD directive and the docker run command, we can execute multiple commands with the docker-compose tool.
RUN is an image build step, the state of the container after a RUN command will be committed to the container image. A Dockerfile can have many RUN steps that layer on top of one another to build the image. CMD is the command the container executes by default when you launch the built image.
It looks like you're using backticks. What's in backticks gets executed and the text in the backticks gets replaced by what's returned by the results.
Try using single quotes or double quotes instead of backticks.
Try getting rid of the backticks like so:
RUN for i in x y z; do echo "$i"; done
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With