Skip to content

Instantly share code, notes, and snippets.

@kgust
Last active June 18, 2018 18:08
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 kgust/9f40046581f5057fe1fd498e3cd03779 to your computer and use it in GitHub Desktop.
Save kgust/9f40046581f5057fe1fd498e3cd03779 to your computer and use it in GitHub Desktop.
Docker Tips

Categories

Build

docker-compose build .
docker-compose up --detach

Spring Cleaning

To demonstrate how quickly you can fill your disk run these commands;

df -h # display current disk utilisation
docker run -it mysql:5.7 bash -c 'echo "Hello"'
docker run -it amazonlinux:latest bash -c 'echo "Hello"'
docker run -it ubuntu:trusty bash -c 'echo "Hello"'
docker run -it ubuntu:latest bash -c 'echo "Hello"'
df -h # display final disk utilisation

Now that you’ve filled your disk see if you can recover the space using these commands to list and clean layers, images, and containers:

docker ps --all # list all containers
docker images --all # list all images
docker rmi $IMAGE_SHA # remove image,multiple SHAs permitted
docker rm $CONTAINER_SHA # remove a containers image, multiple SHAs permitted
docker system prune --all --force # burn it all down with gusto (use with caution)
version: '2'
services:
api:
build: .
ports:
- "5000:5000" # forward flask port to your desktop (replace as desired)
depends_on:
- db # this will cause db to be launched prior to launching this container
volumes:
- .:/app # this is an example of a bind mount
db:
image: "mysql:5.7"
ports:
- "3306:3306" # forward mysql port to your desktop
environment:
- MYSQL_ROOT_PASSWORD=secret
FROM amazonlinux:latest
RUN yum install -y \
iputils \
mysql57-devel \
python27-devel \
python27-pip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment