Dockerfile Cmd 'Command Not Found'

Dockerfile CMD `command not found`

You are using wrong quotes. It should be:

CMD ["bash", "npm run lint"]

Command Not Found with Dockerfile CMD

The issue here is the quotes. Use double " quotes.

From Docker Documentation:

The exec form is parsed as a JSON array, which means that you must use
double-quotes (“) around words not single-quotes (‘).

This is applicable for other instructions such as RUN, LABEL, ENV, ENTRYPOINT and VOLUME.

Docker CMD errors with File Not Found

The initContainer had a volume mount that was overwriting a parent dir containing the script after all. I removed the volume mount and the script starts now.

Troubleshooting: Added command and args to the initContainer:

      initContainers:
- name: build-project
command:
- /bin/sh
- '-c'
args:
- >-
ls -la /path/to/script

and found it indeed didn't exist. There was a volume (emptyDir: {}) mounted to one of the parent directories.

Docker CMD command not running after container started while command into the container works fine

EDIT

From the CMD docs, when using the exec format (specifying args in []) you need to use double quotes " instead of single quotes ' since args are parsed as a JSON array. I think you should change your command to:

CMD [ "/sbin/entrypoint.sh" ]

See this answer comparing CMD vs ENTRYPOINT for more information.

You override the container's CMD when you specify the command to run when you start the container. An example is putting bash after the image name: docker run -d -p 80:80 -v /logs:/var/log a2 bash. Instead of running the /sbin/entrypoint.sh script, it's running bash.

You can consider using ENTRYPOINT instead of CMD if you want to make sure the entrypoint script is run on container startup and cannot be overridden.

ENTRYPOINT ["/sbin/entrypoint.sh"]

As David Maze points out in the comments, you could also modify the entrypoint script to only set environment variables and use CMD exec "$@" in the Dockerfile to run apache as a main container process.

docker run $(pwd) command invalid in Windows

The cmd.exe equivalent to $PWD (which is what the tutorial should be recommending instead of the much less efficient $(pwd)) is %cd%

Thus:

docker run -v %cd%:/mnt -p 9090:9090 -w /mnt mytest ./scripts/tests.sh


Related Topics



Leave a reply



Submit