Skip to content

Instantly share code, notes, and snippets.

@lukeawyatt
Last active January 8, 2021 21:20
Show Gist options
  • Save lukeawyatt/8f106360963cfe41f2e3970cb3858ff3 to your computer and use it in GitHub Desktop.
Save lukeawyatt/8f106360963cfe41f2e3970cb3858ff3 to your computer and use it in GitHub Desktop.
Shell: Docker
docker run –i –t --rm ubuntu sh –c /bin/bash
#!/bin/bash
for file in /home/user/docker-active/*.sh; do
echo $file
[ -f "$file" ] && [ -x "$file" ] && "$file"
done
docker system prune -a -f --volumes
# PULL DOCKER IMAGES
echo "1) PULLING IMAGE"
docker pull AUTHOR/REPO:VERSION_TAG
echo;echo;
# STAGE ENVIRONMENT
echo "2) STAGING ENVIRONMENT"
echo "Creating volume directory..."
mkdir -p /STORAGE/volumes/CONTAINERNAME
echo "Stopping existing container if exists..."
docker stop CONTAINERNAME
echo "Removing existing container if exists..."
docker rm CONTAINERNAME
echo;echo;
# RUN CONTAINERS
echo "3) RUNNING CONTAINER"
docker run \
--volume /STORAGE/volumes/CONTAINERNAME:/data \
--restart=unless-stopped \
--publish=3000:3000 \
--detach=true \
--name=CONTAINERNAME \
AUTHOR/REPO:VERSION_TAG
echo;echo;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment