Skip to content

Instantly share code, notes, and snippets.

@boris
Created March 12, 2022 03:04
Show Gist options
  • Save boris/5823925ce39da2dab0df6306b312eecc to your computer and use it in GitHub Desktop.
Save boris/5823925ce39da2dab0df6306b312eecc to your computer and use it in GitHub Desktop.
Run script on docker init
FROM ubuntu
COPY script.sh /tmp/script.sh
RUN chmod +x /tmp/script.sh
CMD ["bash", "-c", "/tmp/script.sh"]
 docker build -t local/test .
Sending build context to Docker daemon 4.096kB
Step 1/4 : FROM ubuntu
---> ba6acccedd29
Step 2/4 : COPY script.sh /tmp/script.sh
---> f3f4498bf017
Step 3/4 : RUN chmod +x /tmp/script.sh
---> Running in fca78ee43c96
Removing intermediate container fca78ee43c96
---> 60e3a72ae0a9
Step 4/4 : CMD ["bash", "-c", "/tmp/script.sh"]
---> Running in e15ae71ebfce
Removing intermediate container e15ae71ebfce
---> 6c136346a3af
Successfully built 6c136346a3af
Successfully tagged local/test:latest
 docker run local/test
hello!
Sat Mar 12 03:02:53 UTC 2022
This is a message
#!/bin/bash
echo "hello!"
echo "This is a message" > aa
echo $(date)
cat aa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment