Last active
October 20, 2019 17:37
-
-
Save marianabocoi/f9a6772faf18278fd1d2da11e252b1be to your computer and use it in GitHub Desktop.
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
# This file | |
j.mp/pink-docker | |
__________________________________________________________________ | |
# Mac Install | |
# To install brew run one liner from https://brew.sh | |
brew cask install docker | |
# Windows install | |
# https://docs.docker.com/toolbox/overview/#whats-in-the-box | |
# unfortunately you have to enable Virtualization in bios | |
# Linux install | |
# https://docs.docker.com/install/linux/docker-ce/ubuntu/ | |
__________________________________________________________________ | |
# Hello World | |
# To check it is installed and running | |
docker run hello-world | |
__________________________________________________________________ | |
#run a specific opperating system containers | |
# more images at https://hub.docker.com | |
docker run -it --rm ubuntu bin/bash | |
docker run -it --rm centos bin/bash | |
docker run -it --rm alpine /bin/ash | |
# exit container with control+D | |
# Python | |
docker run -it --rm python:3.5 bin/bash | |
#Java | |
docker run -it --rm java:9 bin/bash | |
__________________________________________________________________ | |
# List all containers | |
docker ps -a | |
# List all images | |
docker images | |
__________________________________________________________________ | |
# Bind kittens folder in docker container | |
mkdir kitten | |
docker run -it --rm -v $(pwd)/kitten:/kitten python:3.5 bin/bash | |
# run terminal in existing container | |
docker ps | |
docker exec -it <CONTAINER ID> bin/bash | |
__________________________________________________________________ | |
# Access stopped container | |
# Start container... | |
docker run -it python:3.5 bin/bash | |
# Exit container with control+D | |
# Because we did not use -rm you can see the stopped container when listing all | |
docker ps -a | |
# Start conainer again | |
docker start <CONTAINER ID> | |
# Use same command to go into a running container as above | |
docker exec -it <CONTAINER ID> bin/bash | |
__________________________________________________________________ | |
# Docker cleanup | |
# Stop a running container | |
docker stop <CONTAINER ID> | |
# Kill a running container | |
docker kill <CONTAINER ID> | |
# Delete a stopped container | |
docker rm <CONTAINER ID> | |
# Delete a docker image | |
docker rmi <IMAGE ID> | |
__________________________________________________________________ | |
# Cleanup everything | |
# Kill all running containers | |
docker kill $(docker ps -q) | |
# Delete all stopped containers (including data-only containers) | |
docker rm $(docker ps -a -q) | |
# Delete all 'untagged/dangling' (<none>) images | |
docker rmi $(docker images -q -f dangling=true) | |
# Delete ALL images | |
docker rmi $(docker images -q) | |
__________________________________________________________________ | |
# Basic Dockerfile content | |
FROM python | |
COPY hello.py /hello.py | |
RUN pip install requests | |
# hello.py | |
print("Hello Pink") | |
# Build with following command in the same directory | |
__________________________________________________________________ | |
# More under the hood - docker implementation specifics - do not need for just running | |
# https://medium.freecodecamp.org/demystifying-containers-101-a-deep-dive-into-container-technology-for-beginners-d7b60d8511c1 | |
# Tutorial for dockerising Flask app | |
# https://runnable.com/docker/python/dockerize-your-flask-application |
#Java
docker run -it --rm java:9 bin/bash
Command line help
- some more on bash command basics https://www.unr.edu/research-computing/the-grid/using-the-grid/bash-commands
- starter guide to windows command line https://www.digitalcitizen.life/command-prompt-how-use-basic-commands
- longer list of windows command line commands https://www.computerhope.com/overview.htm
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
docker toolbox for windows:
https://docs.docker.com/toolbox/overview/#whats-in-the-box