Skip to content

Instantly share code, notes, and snippets.

@retgits

retgits/nginx.sh Secret

Created April 30, 2019 16:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save retgits/034d4907f064c4ceb43ef586996d536c to your computer and use it in GitHub Desktop.
Save retgits/034d4907f064c4ceb43ef586996d536c to your computer and use it in GitHub Desktop.
nginx script for DockerCon 2019 demo
# Let's make sure no lingering volume can impact the demo
docker volume rm nginx-vol
# Create a container with a Docker volume attached
docker run -d --name=nginxtest --mount source=nginx-vol,destination=/usr/share/nginx/html -p 8080:80 nginx:latest
# Create a backup of the volume
docker run --rm --mount source=nginx-vol,destination=/usr/share/nginx/html -v $(pwd):/backup alpine:3.9 sh -c "apk add --no-cache zip && zip -r /backup/backup.zip /usr/share/nginx"
# Remove the container and the volume because that's what we need
docker stop nginxtest && docker rm nginxtest
docker volume rm nginx-vol
# Unzip it to make a quick change
unzip backup.zip
code usr/share/nginx/html/index.html
zip -r nginx.zip usr/
# Upload to Artifactory
jfrog rt u --build-name=docker-volume-build --build-number=1 nginx.zip generic-local/
jfrog rt bp docker-volume-build 1
jfrog rt bpr --status=production --comment="Ready for production" docker-volume-build 1 generic-prod
rm -rf usr && rm nginx.zip
# Download the file from Artifactory
jfrog rt dl generic-prod/nginx.zip
# Create a volume again
docker run --rm --mount source=nginx-vol,destination=/usr/share/nginx/html -v $(pwd):/backup alpine:3.9 sh -c "cd / && unzip /backup/nginx.zip"
# Let's see if it worked
docker run -d --name=nginxtest --mount source=nginx-vol,destination=/usr/share/nginx/html -p 8080:80 nginx:latest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment