Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/emmyaniedev/docker-tutorial

This repository contains a Python-based project configured to run in a Docker container. It includes the necessary Dockerfile and configuration files to set up the environment, install dependencies, and ensure seamless deployment and scalability.
https://github.com/emmyaniedev/docker-tutorial

Last synced: 13 days ago
JSON representation

This repository contains a Python-based project configured to run in a Docker container. It includes the necessary Dockerfile and configuration files to set up the environment, install dependencies, and ensure seamless deployment and scalability.

Awesome Lists containing this project

README

        

DOCKER
Docker is a platform that allows you to develop, ship, and run applications inside containers. and deploy as one package.
Containers are lightweight, standalone, and executable software packages that include everything needed to run a piece of software,
including the code, runtime, libraries, and system tools.

Key Concepts
- Dockerfile: A text file that contains a series of instructions on how to build a Docker image.
- Docker Image: A read-only template used to create Docker containers. Images are built from Dockerfiles, and cannot be changed, to change an image we need to build a brand new image and add the changes.
- Docker Container: A runnable instance of an image. Containers can be started, stopped, and deleted. Each container is isolated but can communicate with other containers through defined channels.
- Docker Hub: A cloud-based repository where you can store and share Docker images.

DOCKER IMAGES

Images are BLUEPRINT for containers. they contain below

- Runtime environment
- Application code
- Dependencies
- Extra configuration (e.g. env variables)
- commands

DOCKER VOLUMES

Docker volume is a way to store data outside of a Docker container.
It allows you to persist data across container restarts and share data between containers.

This is a feature of docker that allows us to specify folders on our host computer that can be made available to running containers,
and we can map those folders on our host computer to specific folders inside the container,
so that if something change in those folders on our host computer,
that change will also be reflected to those folders we mapped to inside the container.

*Note* The image the container is running does not change itself.
So if we want to update the image to share with others or create new containers, we have to rebuild the image using docker build.

DOCKER COMPOSE
Docker Compose is a tool for defining and running multi-container Docker applications.
It allows you to define your application's services, networks, and volumes in a docker-compose.yml file,
which makes it easier to manage and run your Docker environment.

BUILD AN IMAGE
docker build -t .
docker build -t flask-docker -f api/Dockerfile .

BUILD AN IMAGE GIVING IT A VERSION NUMBER
docker build -t : .

LIST OF IMAGES
docker images

RUN AN IMAGE / CREATE A CONTAINER
docker run --name

RUN AN IMAGE / CREATE A CONTAINER MAPPING CONTAINER'S PORT TO OUR COMPUTER'S PORT
docker run --name -p 4000:4000 -d

RUN AN IMAGE WITH VERSION NUMBEDR
docker run --name -p 4000:4000 -d :

RUN AN IMAGE WITH WITH DOCKER VOLUME WITHOUT DOCKER COMPOSE
*add this to the docker file beneath "ENV FLASK_APP=main.py"* ENV FLASK_ENV=development
docker run --name flask-docker-container -p 4000:4000 -v $(pwd):/app -d flask-docker-image

BUILD AND RUN AN IMAGE USING DOCKER COMPOSE
docker-compose up --build

STOP THE CONTAINERS
docker-compose down

LIST OF RUNNNING CONTAINERS
docker ps

LIST OF ALL CONTAINERS
docker ps -a

STOP A RUNNING CONTAINER
docker stop or

RESTART A CONTAINER
docker start

DELETE AN IMAGE
docker image rm

DELETE AN IMAGE STILL IN USE
docker image rm -f

DELETE A CONTAINER
docker container rm

DELETE MULTIPLE CONTAINER
docker container rm

DELETE ALL CONTAINERS, IMAGES AND VOLUMES
docker system prune -a