0

Input: - There is Windows machine with Docker Toolbox installed. - There is a shell script file baz.sh which calls py2dsc-deb.

Problem: py2dsc-deb is not available on Windows.

As I understand correctly, I can pull some Linux distro image from Docker repository, create a container and then execute shell-script file and it will run py2dsc-deb and do its job.

I have pulled:

debian - stretch-slim - 3ad21 - 3 weeks ago - 55.3MB

Now

  1. How do I run my script using debian, something like: docker exec mycontainer /path/to/test.sh?

  2. Running docker --rm debian:stretch-slim does nothing. Doesn't it suppose to run Debian distro at docker-machine ip?

  3. I have tried to keep the container up using docker run -it debian:stretch-slim /bin/bash, then run the script using docker exec 1ef5b ./build.sh, but getting

$ docker exec 745 ./build.sh rpc error: code = 2 desc = oci runtime error: exec failed: container_linux.go:247: starting container process caused "exec: \"./build.sh\": stat ./build.sh: no such file or directory"

Does it mean I can't run external script and has to always pass it inside the Docker?

2 Answers 2

1

You can execute bash command inside your container by typing

docker exec -ti -u `username` `container_name` bash -c "cd /path/to/ && ./test.sh"

lets say your container name is test_buildbox, you are root and your script stays inside /bin/test.sh You can call this script by typing

docker exec -ti -u root test_buildbox bash -c "cd /bin/ && ./test.sh
Sign up to request clarification or add additional context in comments.

1 Comment

I added an explanation with an example
0

Please check if you have correct line endings in your .sh scripts (<LF>) when you built Docker image on Windows.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.