Giter VIP home page Giter VIP logo

docker_course's Introduction

Docker 🐳

What is Docker πŸ˜„

  • Docker is a set of platform as a service products that use OS-level virtualization to deliver software in packages called containers. Containers are isolated from one another and bundle their own software, libraries and configuration files; they can communicate with each other through well-defined channels. All containers are run by a single operating-system kernel and are thus more lightweight than virtual machines. Containers are created from images that specify their precise contents. Images are often created by combining and modifying standard images downloaded from public repositories.

Why do you need docker πŸ€”

  • to solve the compatibility issue between different operating systems and different versions of the same operating system and different environments and different versions of the same environment

  • Docker is a tool designed to make it easier to create, deploy, and run applications by using containers. Containers allow a developer to package up an application with all of the parts it needs, such as libraries and other dependencies, and ship it all out as one package. By doing so, the developer can rest assured that the application will run on any other Linux machine regardless of any customized settings that machine might have that could differ from the machine used for writing and testing the code.

What can it do for you πŸ€·β€β™‚οΈ

  • with docker you can run each service in a separate container with its own dependancies and libraries ,and each container will have its own IP address and port number. This means that you can run multiple instances of the same service on the same server without any conflicts. This is a huge advantage over running multiple instances of the same service on the same server using virtual machines.

What are Containers πŸ“¦

  • container is completely isolated environment for running applications and each container has its own process space, network interface, and filesystem. Containers are lightweight because they don’t need the extra load of a hypervisor, but they all share the os kernel. This means they require less memory than virtual machines (VMs). Containers are also more portable and efficient. You can build images locally, store them in a private registry, and deploy them to any infrastructure that supports Docker containers.

  • A container is a standard unit of software that packages up code and all its dependencies so the application runs quickly and reliably from one computing environment to another. A Docker container image is a lightweight, standalone, executable package of software that includes everything needed to run an application: code, runtime, system tools, system libraries and settings.

Container vs Image πŸ“Έ

  • An image is a read-only template with instructions for creating a Docker container. A container is a runnable instance of an image. You can create, start, stop, move, or delete a container using the Docker API or CLI. You can commit your container’s changes into a new image using the Docker commit command. You can push and pull images from Docker registries.

Docker Commands πŸ“

- RUN πŸƒβ€β™‚οΈ

1- Run or start a container

   docker run 'image name'

1.1- Run a version of an image

   docker run 'image name':'tag'

# if you don't specify the tag then the latest version will be used ny default

1.2- Run STDIN

   docker run -i 'image name'

# this command will run the container and will allow you to execute commands inside the container
   docker run -it 'image name'

      # this command will run the container and will allow you to execute commands inside the container and will attach to the container

1.3- Append a command

   docker run 'image name' 'command'

1.4- Run a container in the background

   docker run -d 'image name'

1.5- Run a container in the foreground

   docker run -it 'image name'

      # this command will run the container and execute the command inside the container

1.6- Run a container in the foreground and attach to it

   docker attach 'container id/name'

     # this command will attach to a running container and will allow you to execute commands inside the container

1.7- Run - PORT MAPPING

   docker run -p 'host port':'container port' 'image name'

      # this command will run the container and will map the container port to the host port to allow the host to access the container port from outside the container

1.8- Run - VOLUME MAPPING

   docker run -v 'host path':'container path' 'image name'

- environment variables 🌎

1.9 - set environment variables

   docker run -e 'environment variable name'='environment variable value' 'image name'

1.10 - set environment variables from a file

   docker run --env-file 'environment variables file path' 'image name'

1.11 - inspect environment variables

   docker inspect 'container id/name'

      # this command will return the container details that contains the environment variables in a json format

- LIST πŸ“œ

2- List containers

   docker ps

2.1- List all containers

  docker ps -a

2.2- List images

   docker images

- Stop a container πŸ›‘

  docker stop 'container id/name'

- Remove a container πŸ—‘

  docker rm 'container id/name'

- Remove an image πŸ—‘

  docker rmi 'image id/name'

      # but you have to make sure that the image is not used by any container

- Download an image πŸ“₯

  docker pull 'image name'

      # also the image will be downloaded automatically when you run a container if the image is not already downloaded

- Execute a command to a running container ⏭️

   docker exec 'container id/name' 'command'

      # this command will run the container in the background and will return the container id

- Inspect a container πŸ•΅οΈβ€β™‚οΈ

   docker inspect 'container id/name'

      # this command will return the container details in a json format

- Container logs πŸ“

   docker logs 'container id/name'

Create Docker image πŸ“¦

Dockerfile πŸ“„

  • Docker file is a text written in a specific format that docker can understand and use it to build an image

  • evert thing in the left in capital letters is a command or an instruction each instruction makes docker perform a specific task

  • A Dockerfile is a text document that contains all the commands a user could call on the command line to assemble an image. Using docker build users can create an automated build that executes several command-line instructions in succession.

  • when you were buiding an image you were actually running a series of commands that were written in the docker file

  • while building the image if any failure happens the image will not be created but docker will cache the previous steps/layers until the failure step and will not run the steps after the failure step

  • when the faulure step is fixed and the image is built again docker will not run the steps that were already run before the failure step and will use the cached layers and run the failed step then the steps after the failure

NetWorks in Docker πŸ•ΈοΈ

  • Docker networks are the virtual networks that are used to connect the containers together

  • Docker networks are isolated from each other and they are not connected to the host network

  • Docker networks are created using the docker network command

       docker network create 'network name'
    
  • Docker networks can be created in 3 different modes

    • Bridge: the default mode
    • Host : the host network
    • None : no network
  • Docker networks can be connected to each other using the docker network connect command

       docker network connect 'network name' 'container name'
    
  • Docker networks can be disconnected from each other using the docker network disconnect command

       docker network disconnect 'network name' 'container name'
    
  • Docker networks can be removed using the docker network rm command

       docker network rm 'network name'
    
  • Docker networks can be listed using the docker network ls command

       docker network ls
    
  • Docker networks can be inspected using the docker network inspect command

       docker network inspect 'network name'
    

Docker Compose πŸ“

Docker concepts in depth πŸ“š

Docker Swarm 🐳

Docker vs Kubernetes 🐳 vs πŸ•ΈοΈ

each operating system consists of OS Kernel and a set of applications and libraries that are used to run the operating system

the os kernel is the core of the operating system and it is responsible for managing the hardware resources and the applications and libraries that are used to run the operating system

docker_course's People

Contributors

mo2men-5aled avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.