Reputation: 5989
I have dockerfile
CMD [ "/run/myfile.sh" ]
I build it
docker build . -t myRepo/test/my-app:1.0.0
and run it
docker run -it --rm myRepo/test/my-app:1.0.0 sh
If I want to change the CMD with more parameters How I can do it ? for example I want to create folder
command: ["/bin/sh"]
args: [ "-c", "mkdir -p /myfolder/sub && mkdir -p /myfolder2/sub2"]
I tried
docker run -it --rm myRepo/test/my-app:1.0.0 sh [ "-c", "mkdir -p /myfolder/sub && mkdir -p /myfolder2/sub2"]
Upvotes: 0
Views: 586
Reputation: 1838
If you need to run multiple commands, try to use entrypoint.sh
Just create a shell script, for example:
#!/bin/sh
mkdir -p /foo/bar
mkdir -p /foo2/bar2
#whatever
And edit your Dockerfile:
COPY entrypoint.sh /usr/local/bin/
CMD ["entrypoint.sh"]
But I'm not sure it's your case, creating directories are better in RUN
commands, not CMD
:
FROM centos:7
RUN mkdir -p /foo/bar/ && mkdir -p /foo2/bar2/
RUN ...
COPY entrypoint.sh /usr/local/bin/
CMD ["entrypoint.sh"]
Upvotes: 1