Created
March 30, 2020 16:45
-
-
Save jeremyckahn/91d9edb7fb7a0f81fed573c229d335a8 to your computer and use it in GitHub Desktop.
Run a shell script in a Docker environment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker run \ | |
# Set the current host working directory as the container's /tmp so the container can access it | |
-v $(pwd):/tmp \ | |
# Mount your home directory as the Docker root user's home directory to inherit any host dotfiles | |
-v $HOME:/root \ | |
# (Effectively) set the host's working directory as the container's working directory | |
-w /tmp \ | |
# Set any environment variables you need (feel free to add as many as you need, each with a new --env switch) | |
--env ENV_VAR=$ENV_VAR \ | |
# Select whatever image makes the most sense for you here | |
-i node:latest \ | |
# Run your script | |
/bin/bash -c path/to/script.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment