What is the difference between Docker and Docker-Compose?
+ Docker is the Enginee where Containers run.
+ Docker-Compose is a irchestrator where you can define services with multiple images.
What is the first line that a YAML archive, of docker-compose must start?
VERSION <version_id>
The VERSION of Docker Compose that is working with.
(*) You should valid the compatibility of the version against Docker Enginee
What is the difference between these commands?
$docker-compose --version$docker compose versionNothing, both of them are valid but you only are able to use docker compose since the upgrade to Docker Compose V2.x.
What is a Compode YAML File?
The Compose file is a YAML file defining version (DEPRECATED), services (REQUIRED), networks, volumes, configs and secrets.
https://docs.docker.com/compose/compose-file/
What is the defaul path of Compose File?
compose.yaml or compose.yml
https://docs.docker.com/compose/compose-file/
In a Compose File, Is this path, in VOLUMES, valid for a windows as a linux enviroment?
yaml volumes: - ./mypath:myfile_datbase.d
YES.
Docker File need this notation and it’s able to translate the path to use the separator that OS needs (\ or /).
How can you define Services in a docker compose file?
Declaring them after the VERSION into the STATEMEN services: which is at the same level than VERSION:
```YAML
version: ‘3.1’
services:
#My Service
my_service:
~~~
How can you tell to docker compose how to download an image and install it:
From a secction of a service, you must define the name of the image to downlad and install it, using the property image:<image_name>:<tag>:
```YAML
services:
#database engine service
postgres_db:
container_name: postgres
image: postgres:latest
~~~
How can you tell to docker compose building a new image from a Dockerfile?
Defining into the service propertyes the service’s statement build:
YAML
billingapp-back:
build:
context: ./java
args:
- JAR_FILE=*.jar
In this YAMLE segment, what is the function of context:
YAML
billingapp-back:
build:
context: ./java
args:
- JAR_FILE=*.jar
Define the conextx where de Dockerfile is in reference of the path where the docker-compose is executed.
In this code
1. What is the function of volumes?
2. How does it work?
```YAML
services:
postgres_db:
container_name: postgres
image: postgres:latest
restart: always
ports:
- 5432:5432
volumes:
data directory is empty
- ./dbfiles:/docker-entrypoint-initdb.d
- /var/lib/postgres_data:/var/lib/postgresql/data
~~~
In this services declaration, what is the function of enviroment? and how does it works?
```YAML
billingapp-back:
build:
context: ./java
args:
- JAR_FILE=*.jar
container_name: billingApp-back
environment:
- JAVA_OPTS=
-Xms256M
-Xmx256M
~~~
It will declare Enviroment Variables that will be used in a Dokerfile. in this case the JAVA_OPTS is used in Dockerfile as:
```YAML
FROM openjdk:8-jdk-alpine
RUN addgroup -S devopsc && adduser -S javams -G devopsc
USER javams:devopsc
ENV JAVA_OPTS=””
~~~
In this service declaration, what is the function of depends_onproperty?
```YAML
billingapp-back:
build:
context: ./java
args:
- JAR_FILE=*.jar
container_name: billingApp-back
depends_on:
- postgres_db
ports:
- 8080:8080
~~~
depends_on to run.```YAML
services:
#database engine service
postgres_db:
container_name: postgres
…
#database admin service
adminer:
…
depends_on:
- postgres_db
ports:
- 9090:8080
~~~
What is the command to “compile” and build service from a docker-compose YAML file?
docker-compose -f <file.yaml> build
How to initialize (run) all the services defined ina Docker Compose File (YAML) and deatach from console?
docker-compose -f <file.yaml> up -d
-d is for deatach the proccess from console.
How to stop all the services defined ina Docker Compose File (YAML) that are already running?
docker-compose -f <file.yaml> stop
What is the basic command to know the resources that each container is using?
docker stats
What is the command to deploy a YAML File and recreate its containers?
docker-compose -f <YAML File> up -d --force-recreate
--force-recreate to recreate the containers
- d to deatache from the console
Wha is the correct way to set limit of resource of memory into a serivice configuration?
deploy:
resources:
limits:
cpus: "0.15"
memory: 250MWha is the correct way to set the inital resources that a service must use on running?
deploy:
reservations:
cpus: "0.1"
memory: 128MWhat is the mistake in this declaration of resource limits?
deploy:
resources:
limits:
cpus: "0.15"
memory: 250M
reservations:
cpus: 0.1
memory: 128MThat the cpus MUST be delcared with cuotes ("0.1").