Docker - MateuszMazurkiewicz/coding-and-learning GitHub Wiki
Resources:
- Docker For Beginners: From Docker Desktop to Deployment
- Docker Tutorial for Beginners - A Full DevOps Course on How to Run Applications in Containers
- Docker Tutorial for Beginners [FULL COURSE in 3 Hours]
Notes:
Basics
Docker - container management software Docker Image - file, comprised of multiple layers, that is used to execute code in Docker Container Docker Container - running instance of Docker Image
VM vs. Docker - VM uses virtualized hardware (using Hypervisor) and guest Operating System on it (heavy), Docker Container virtualizes OS (light and portable)
Docker Hub - repository of Docker Images
Commands
Dockerfile Commands:
FROM(define basic image),RUN(run terminal command),WORKDIR(change directory),COPY(copy form local to docker image),EXPOSE(expose port),CMD [...](command to run in container withdocker runor to pass default parameter afterENTRYPOINT)ENTRYPOINT [...](command to run in container withdocker run 'parameters'with parameters from terminal)
Docker Commands:
docker buildto build image,-t 'image name':version.docker imagesto list all images.docker run,-itruns container in interactive mode,-p 'port on the Docker host'/'port in the container'maps port between host and container (default TCP),-v 'host directory':'container directory'mounts volumes to keep them on host,-e 'VARIABLE NAME'='value'sets env variable,--name 'name'sets container namedocker psshows running containersdocker login -u 'username'docker tag 'image id' 'name:tag'docker push 'name:tag'docker pull 'name:tag'docker inspect 'image id'
Example: link(https://github.com/MateuszMazurkiewicz/coding-and-learning/blob/main/Dockerfile)
Docker-Compose
docker-compose- takes multiple containers and makes them run together as an application. Use .yml file to define services and parameters for each servicedocker-compose upto run all services,-din detached statedocker-compose downto stop services
Example: link(https://github.com/MateuszMazurkiewicz/coding-and-learning/blob/main/docker-compose.yml)