Dockers are containers for your applications to run on any device/OS. This repo contains commands & setup instructions to deploy a python app to a Docker.
- Build a simple app (python)
- Install Docker on your device
- Setup Docker using CLI commands
docker --versiondocker initdocker build -t sample-docker .Run the image 'sample-docker' on localhost (127.0.0.1) by mapping the port 8080 of localhost & docker
docker run -p 127.0.0.1:8080:8080 sample-dockerYour app should be live on http://127.0.0.1:8080/
docker run -v C:\Users\u1\Documents:/container_folder sample-dockerdocker volume create sample-shared-volume
docker run -v sample-shared-volume:/container_folder sample-dockerdocker run -v sample-shared-volume:/container_folder -p 127.0.0.1:8080:8080 sample-docker- Volumes allow data (database & files) to persist even after container shuts down
- Host source is denoted by
C:\..(Windows) or/path/to/folder(Linux/Mac) - Destination container is denoted by directory after
:/folder-name - Use
-pflag to map ports between host and container - Use
-vflag to create volume mounts
| Command | Purpose |
|---|---|
docker --version |
Check Docker version |
docker init |
Initialize Docker in current directory |
docker build -t <name> . |
Build image from Dockerfile |
docker run -p <host>:<container> <image> |
Run container with port mapping |
docker volume create <name> |
Create named volume |
docker run -v <source>:<dest> <image> |
Run with volume mount |