Running Docker on Mac, I can build my image, but on running, I get the following error:
/bin/sh: 1: [: missing ]
I create the image in a local directory with a dockerfile, requirements.txt and a python script file. - 3 files- using docker build
Dockerfile:
FROM python
COPY "requirements.txt"
RUN pip install -r requirements.txt
COPY "quandlData.py"
CMD [ "python", "./quandlData.py"
-simple script that gets some data from quandl API and writes-gets from a redis server- which is running. To run, I just use docker run image_name
You can even now run ARM or Intel Docker containers on the Apple M1 Mac with Docker Desktop for Mac M1. The default, of course, is to run the ARM version but if you use the –platform linux/amd64 parameter Docker will run the Intel version for you.
On a Mac, the default location for Docker images is ~/Library/Containers/com. docker.
CMD [ "python", "./quandlData.py"
is being parsed as a shell command, not an array -- and the [
command (when invoked that way, rather than by its alternate name test
) requires its last argument to be ]
.
In this case, however, adding a trailing ]
will cause your CMD
to parse as an array describing arguments to pass to python
, not a [
command at all -- which it should be.
Thus, you can do either of these two things:
# BETTER: Fix your JSON array
CMD [ "python", "./quandlData.py" ]
...or...
# WORSE: Pass a valid shell command
CMD python ./quandlData.py
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