You don't need to run any docker commands as
boot2docker as every command passed into the
boot2docker VM runs as root by default.
You're seeing the error when you're running as
sudo doesn't have the
DOCKER_HOST env set, only
your user does.
You can confirm this by doing a:
$ sudo env
And looking for
DOCKER_HOST in each output.
As for having a docker file that runs your script, something like this
might work for you:
# Copy your script into the docker image
ADD /path/to/your/script.sh /usr/local/bin/script.sh
# Run your script
Then you can run:
docker build -t your-image-name:your-tag .
This will build your docker image, which you can see by doing a:
Then, to run your container, you can do a:
docker run your-image-name:your-tag
This run command will start a container from the image you created with
Dockerfile and your build command and then it will finish
script.sh has finished executing.