Dev Space
DemoGitHubDiscord Server
  • 🏠Dev Space
  • 💡Features
  • 📄Changelogs
  • â„šī¸Credits
  • Guides
    • 🌐Website Guides
      • Install Dev Space Website
    • ⚡Agent Guides
      • Install Dev Space Agent
  • MongoDB Guides
    • MongoDB Admin
  • What is docker?
  • Accounts
    • 🙂Profile
  • Teams
    • đŸ˜ī¸Teams
    • 🔒Permissions
    • 🤖API
      • Client
      • Console
      • Docker
      • Roles
      • Members
      • Servers
      • Users
      • Models
  • Team Resources
    • đŸ–Ĩī¸Servers
    • 🎮Consoles
Powered by GitBook
On this page
  • Docker?
  • Registry?
  • Containers?
  • Networks?
  • Stacks
  • Example?
  • Better Example

What is docker?

PreviousMongoDB AdminNextProfile

Last updated 23 hours ago

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 for example the website container can access the API container in its own network.

Registry?

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.

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.

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.

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.

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

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

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 and can be used to create and start containers with those tools.

https://hub.docker.com/