Last active
January 17, 2022 13:52
-
-
Save dkatz23238/037948c31058c2c6c37e40dc0e56c634 to your computer and use it in GitHub Desktop.
Docker training 2022 scripts
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
# Run a container | |
docker run -it python:latest bash | |
# or | |
# will start the container using latest CMD or ENTRYPOINT | |
docker run -it python:latest | |
# Run dettach mode, if you don't the shell session will be attaced to the containers lifecycle | |
docker run -it -d python:latest | |
# Run with env --rm will remove the container upon exit of last proccess. | |
docker run --rm -it -e TRAINING_SESSION=DOCKER python:latest bash | |
# Create a directory to map a volume to and use in the container | |
mkdir /tmp/volume_map/ | |
# You can map any directory on the host into the container and set its location to any valid path | |
docker run -it --rm -e PATH_MAP=/mapped_volume -v /tmp/volume_map:/mapped_volume python:latest bash | |
# Create a new network | |
docker network create docker-training | |
docker run --rm --network docker-training --name redis -e ALLOW_EMPTY_PASSWORD=yes bitnami/redis:latest | |
docker run --name redis-client --rm -it --network docker-training python:latest bash | |
# python -m pip install redis | |
# Ipython | |
# r = redis.Redis(host='redis', port=6379, db=0) | |
# r.set("myvariable","myvalue") | |
# print(r.get("myvariable")) | |
# View images | |
docker image ls | |
# Build a new image | |
docker build -f Dockerfile name:tag | |
# Stop a running container | |
docker stop CONTAINERID | |
# Remove container | |
docker rm CONTAINERID | |
# Connect to a running container | |
docker exec -it bash DOCKER_CONTAINER_ID |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment