How to cook 👨🍳 Docker with React. Part 1 — Base Theory and commands.
If you can create a container — do it!
Docker. For what?
Docker allows to create and run packed containers.
Container — isolated environment with application (or without). With this application can interact OS where this container is run.
So we can run as many apps with their environment as we wish :) Without any installations, only Docker. At the same time these apps can interact with each others.
Terms of Docker
- Docker daemon — a service for working with containers.
- Docker client — cli for daemon management Docker daemon (^).
- Docker image — unchangeable file which can run container. Applications being packed exactly in images, from whom runs containers.
- Dicker container — runned from image working (hope so) application.
- Docker registry — repository (storage) with docker images.
Dockerfile — file-instruction how to build docker image.
Use the Docker command line
To list available commands, either run docker with no parameters or execute docker help: Depending on your Docker…
Main (useful) commands of Docker CLI
- run — command for running container. The docker run command first creates a writeable container layer over the specified image, and then starts it using the specified command.
- push — pushes image to repository
- ps — shows the list of containers
- attach — connects to running container
- rm — deletes container(s)
- rmi — deletes image(s)
- start/stop/restart — action with container :)
- build — creates image from Dockerfile
Main (useful) commands Dockerfile
- FROM — initalizes new step of building and sets base image
- RUN — executes command in a container. Execute any commands in a new layer on top of the current image and commit the results. The resulting committed image will be used for the next step in the Dockerfile.
- ENV — sets env variable
- WORKDIR — sets working directory, where next commands will be executed
- CMD — sets default args for container’s ENTRYPOINT
- ENTRYPOINT — configures what will be runned on container’s start
- EXPOSE — “says” to the Docker which port should listen container on running
- COPY — copies files from to container
- For the app instruction’s creation (how, where and what app should to do) exists Dockerfile
- For running commands Docker as service and image’s creation and then running exists Docker CLI
As more claps I get as soon Practice part comes :)