# What is docker?

### Docker?

Docker is a system service that allows you to create sandboxed applications that have their own network, storage, operating system and packages that can't access the host system.

This uses virtualization and various other features to allow for easy hosting and development of websites, databases and programs which can access shared networks and volumes.

<figure><img src="/files/9Bg856uuSZlW52WIAmIp" alt=""><figcaption></figcaption></figure>

### Registry?

The docker registry is an archive of system images that have pre-built features and tools for your container to use, you can pull images from the registry which will download them from <https://hub.docker.com/> and can be used to create and start containers with those tools.

This could be standard operating systems like Ubuntu, Python/Node library, Database programs and other frameworks that have been made by the community or companies.

### Containers?

Once you have downloaded an image from the registry you can use them to create as many containers as you like from them.

You can also add your own files to the container by using docker volumes that use a predefined directory or binding a directory to the host directory.

<div align="left"><figure><img src="/files/09hThkEVtJb8tB27jm0J" alt=""><figcaption></figcaption></figure></div>

### Networks?

Networks allows you to connect your containers together so that they can communicate which each other and can use multiple networks.

In this example Container 1 (Web App) can access Container 2 (API) and Container 3 (Database) can only be accessed by the API container.

This is also a good way to secure your containers so that unauthorized access or requests can't access your other resources.

<figure><img src="/files/qGe64zn0StivbEhkyXYt" alt=""><figcaption></figcaption></figure>

### Stacks

Stacks is a term for deploying and running multiple containers in a group using a config file to build the docker resources (Networks, Containers and Volumes)

In production you will usually create a stack which contains the frontend container, backend container and database container to run the entire setup.

<figure><img src="/files/Po3NZBnD1XSfQsKcg3yl" alt=""><figcaption></figcaption></figure>

### Example?

Here is an example of a stack and a single container.

* It will download or use the .net aspnet library version 9.0
* The environment variables to set for the application.
* Which volumes to use, this is a bind mount which uses files from the host system.
* Restart is an optional property that lets you restart containers during unexpected failures, this example will restart on failures and retry up to 3 times.
* The work directory is where to start the application and the commands used to setup and run the application when you start the container.

```yaml
services:
  devspace-demo:
    container_name: "devspace-demo"
    image: mcr.microsoft.com/dotnet/aspnet:9.0
    command: sh -c "apt-get update && apt-get install -y curl && apt-get install -y fontconfig && ./DevSpaceWeb"
    environment:
      - ASPNETCORE_ENVIRONMENT=Production
    volumes:
      - /root/services/devspace_web_demo:/app:rw
    working_dir: /app
    restart: on-failure:3
```

### Better Example

In this example it shows how to use networks and volumes with dependencies.

* The web container depends on the database container to be started first.
* The website  and database containers will connect to a network so they can communicate with each other.
* The database container uses a defined docker volume to store the database files.
* The website uses a bind mount to load the website files from and to start in /app

```yaml
services:
  devspace-web:
    container_name: "devspace-web"
    image: mcr.microsoft.com/dotnet/aspnet:9.0
    command: sh -c "apt-get update && apt-get install -y curl && apt-get install -y fontconfig && ./DevSpaceWeb"
    environment:
      - ASPNETCORE_ENVIRONMENT=Production
    volumes:
      - /root/services/devspace_web:/app:rw
    networks:
      - devspace_network
    depends_on:
      - devspace-mongodb
    working_dir: /app
    restart: on-failure:3
  devspace-mongodb:
    container_name: "devspace-mongodb"
    image: mongo:8-noble
    command: --port 5557
    volumes:
      - devspace_mongodb_storage:/data/db
    networks:
      - devspace_network
networks:
  devspace_network:
    name: devspace_network
    driver: bridge
volumes:
  devspace_mongodb_storage:
    name: devspace_mongodb_storage
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.fluxpoint.dev/cloudfrost-dev/guides/what-is-docker.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
