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
How to Merge Two Rows in a Same Row from a Text File in Linux Shell Script
How to Disable Hardware Prefetcher in Core I7
Script Produces Different Result When Executed by Bash Than by Cron
Delete Files with Backslash in Linux
Docker Overlay2: Error Walking File System: Oserror [Errno 40] Too Many Levels of Symbolic Links
Arm: Disabling Mmu and Updating Pc
How to Fix Nginx 502: Bad Gateway Error on a Digital Ocean Droplet - Ubuntu 20.04
Delete Repeated Characters Without Back-Referencing with Sed
Bash - How to Match Files Names to Use in Loop
Safely Remembering Ssh Credentials in Bash Script
Find Command Find Directories That Were Created After a Certain Date Under Linux/Cygwin
Cmsg_Nxthdr() Returns Null Even Though There Are More Cmsghdr Objects
How to Solve "Bash: Ls: Command Not Found"
Cuda 5.0: Replacement for Cutil.H
Script to Check for Process & Restart Program If Not Found
Ssh Connection to Ubuntu Open Ssh-Server Requires Login on (Physical) Server via Password First