Skip to content

Instantly share code, notes, and snippets.

@dev-pmartins
Last active September 14, 2016 15:11
Show Gist options
  • Save dev-pmartins/8f5df7c53b48ffb689e2ac4a8551c11b to your computer and use it in GitHub Desktop.
Save dev-pmartins/8f5df7c53b48ffb689e2ac4a8551c11b to your computer and use it in GitHub Desktop.
# Dockerfile build
## Min Command:
docker build ./ && docker create --name [container_name] -it $(docker images | awk '{print $3}' | awk 'NR==2 {print; exit}') bash && docker start [container_name] && docker exec -it [container_name] bash
## Instruction
docker build ./ && # Build image from Dockerfile ## <- [START CREATION]
docker create --name [container_name] -it $(docker images | awk '{print $3}' | awk 'NR==2 {print; exit}') bash && # Create new container, replace "[container_name]" by container name (Really?)
docker start [container_name] && # Start Container
docker exec -it [container_name] bash # Access created container
# Dockerfile recreate build
## Min Command:
docker stop [container_name] && docker rm -f [container_name] && docker rmi -f $(docker images | awk 'NR==2 {print; exit}' | awk '{print $3}') && docker build ./ && docker create --name [container_name] -it $(docker images | awk '{print $3}' | awk 'NR==2 {print; exit}') bash && docker start [container_name] && docker exec -it [container_name] bash
## Instruction
docker stop [container_name] && # Stop running containers [ONLY IF BUILD ALREADY EXIST]
docker rm -f [container_name] && # Delete old container [ONLY IF BUILD ALREADY EXIST]
docker rmi -f $(docker images | awk 'NR==2 {print; exit}' | awk '{print $3}') && # Remove last image listed on docker (NR2 :: Ignore docker headers) [ONLY IF BUILD ALREADY EXIST]
docker build ./ &&
docker create --name [container_name] -it $(docker images | awk '{print $3}' | awk 'NR==2 {print; exit}') bash &&
docker start [container_name] &&
docker exec -it [container_name] bash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment