-
Notifications
You must be signed in to change notification settings - Fork 144
Docker & Docker Compose
Mehdi Hadeli edited this page Jun 12, 2023
·
41 revisions
- Docker
Build Context
- Docker
Build
- Docker
Run
-
Docker
Multi-stage
builds ⭐⭐ - How do I build a dockerfile if the name of the dockerfile isn't Dockerfile?
- Understanding the Docker Build Context (Why You Should Use Dockerignore) ⭐
- How to Debug Dockerized .NET Core Apps in VS Code ⭐
- Docker images for ASP.NET Core
- .NET 7 SDK built-in container support and Ubuntu Chiseled ⭐
- Optimising .NET Core Docker images ⭐
- Containerize a .NET app with dotnet publish ⭐
- Announcing built-in container support for the .NET SDK ⭐
- Trying out the built-in container support for the .NET SDK
- Linting a .NET 6 app Dockerfile using Hadolint, dockerfile_lint and Azure Pipelines
- Experimenting with .NET 7, WASM, and WASI on Docker
- .NET 6 is now in Ubuntu 22.04
- Tutorial: Containerize a .NET app
- Containerize a .NET app with dotnet publish
- laurentkempe/ChiseledDocker
- How to build and push Docker image with GitHub actions? ⭐
- How to build an optimal Docker image for your application? ⭐⭐
- https://github.com/NuGet/Home/issues/10491#issuecomment-778841003
- Publish error: Found multiple publish output files with the same relative path
- Optimising ASP.NET Core apps in Docker - avoiding manually copying csproj files ⭐
- Exploring the .NET Core Docker files: dotnet vs aspnetcore vs aspnetcore-build ⭐
- Exploring the .NET Core 2.1 Docker files (updated): dotnet:runtime vs aspnetcore-runtime vs sdk ⭐
- Creating a generalised Docker image for building ASP.NET Core apps using ONBUILD ⭐
- Optimizing your .NET Core Docker image size with multi-stage builds ⭐
- Docker Build Process for .NET Applications ⭐
- Demystifying Docker: .NET 6 on Docker + Docker Debugging ⭐
-
Debugging ASP.NET Core apps in a local Docker container
Rider
⭐ - An error, "failed to solve with frontend dockerfile.v0" ⭐
- Communication between multiple docker-compose projects ⭐⭐
-
Networking
inCompose
⭐ -
docker
network create
⭐ - Networks top-level element ⭐
- Showing errors in docker file in docker-run ⭐
- DEBUGGING YOUR .NET CORE IN DOCKER APPLICATIONS WITH VS CODE ⭐⭐
- Attaching to remote processes ⭐
- How to debug a .NET Core app in Docker with VSCode ⭐⭐
- Get started with Docker remote containers on WSL 2 ⭐
- Docker Desktop WSL 2 backend on Windows ⭐
- How to configure Docker Desktop to work with the WSL
- Setting Up Docker for Windows and WSL to Work Flawlessly ⭐
- How to properly override the ENTRYPOINT using docker run ⭐
- ENTRYPOINT (default command to execute at runtime) ⭐
- How to Override Entrypoint Using Docker Run
- Docker RUN vs CMD vs ENTRYPOINT ⭐⭐
- Running as a non-root user
- What's the default user for docker exec?
- Running a Docker container as a non-root user
- Developing ASP.NET Core apps in Docker - Live Recompilation
- Using Docker Buildkit --mount=type=cache for caching Nuget packages for .NET 5 dockerfile ⭐⭐
- Caching NuGet Packages Using --mount=type=cache Seems Broken ⭐⭐
- Docker build caching for .NET applications done right with dotnet-subset
- Best practices for writing Dockerfiles ⭐
- Speed up pip downloads in Docker with BuildKit’s new caching ⭐⭐
- [BUG] docker endpoint for "default" not found #9956
- How to Keep Docker Container Running for Debugging ⭐
- Running Docker Containers Indefinitely
- What does it mean to attach a tty/std-in-out to dockers or lxc?
- Removing unused intermediate docker images automatically
- Enforce HTTPS in ASP.NET Core
- Hosting ASP.NET Core images with Docker over HTTPS
- Docker and .Net — Environment variables and appsettings.json
- Hot-Reload .NET Configuration in Kubernetes with ConfigMaps ⭐
- Testing Chiseled Ubuntu container images with .NET
- use
docker exec -it docker-remote-debugging bash
for interacting with container` - We could use also a predefined network and connect to that predefined network with specifying the
name
of existing network and setexternal
attribute totrue
- When we run
docker-compose up
, Docker Compose will check if the 'ecommerce' network already exists. If it does not exist, it will create the 'ecommerce' network. If it exists, it will use the existing 'ecommerce' network. Problem is that if we do adocker-compose down
this network will delete and other docker-compose that use same network will fail because network deleted, so it's better we useexternal
keyword for using a predefined network - We can use the network that will create by infrastructure docker-compose and use this network in other docker-compose files with the
name
of existing network and setexternal
attribute totrue
for using network that defined outside our docker-compose file. Also, We can create aecommerce
network manually bydocker network create -d bridge ecommerce
and use this network asexternal network
for all docker-compose files - Using the
base image
of theDockerfile
fordebugging
can be more efficient because you don't need to build the entire application from scratch. Instead, you can reuse the already-built layers and add debugging tools and configurations as needed. This can save time and resources, especially if your application is large or complex. - On the other hand, doing a
full build
fordebugging
can ensure that the debugging environment is identical to the production environment. This can help catch issues that may not surface in a modified version of the image, and provide a more accurate representation of the production environment. However, this approach can be slower and require more resources. - we can supply multiple
-f
configuration files. When you supply multiple files, Compose combines them into a single configuration. Compose builds the configuration in the order you supply the files.Subsequent
filesoverride
and add to theirpredecessors
. - if we use
base
image directly for running our mapped debug dll (not published dll, with publish dll depdendent assmblies are there also) it deosn't have all dependet assmblies and in this layer or stage we don't have nugets so we can get nugets that mapped from host machine with volume indocker run
ordocker-compose up
and pass it to --additionalProbingPath in lunching program. for exampledotnet <application.dll> --additionalProbingPath /root/nuget/packages --additionalProbingPath ~/.nuget/packages
- we can use mounted volume in
docker run
ordocker-compose up
for aentrypoint
in dockerfile when docker container will be run for thehost
with--mount type=bind,source=${env:USERPROFILE}\\.nuget\\packages,destination=/root/.nuget/packages,readonly
. for exampledotnet <application.dll> --additionalProbingPath /root/nuget/packages
- When we use
multi stage
build,docker build
uses last stage as output of build and created image and also we can remove intermediat layers that uses for create final stage with usingdocker image prune -f
- for setup
dev certificate
onubuntu
we can use this approuch,dotnet dev-certs https --trust is
only supported on macOS and Windows but we don't get error in our applications and It is likely that you need to trust the certificate in your browser and allow process with none trusted cert.
dotnet dev-certs https -ep ${HOME}/.aspnet/https/aspnetapp.pfx -p <CREDENTIAL_PLACEHOLDER>
dotnet dev-certs https --trust
Also if we use WSL we can use this approuch:
The easiest way to have Windows trust the WSL certificate, is to configure WSL to use the same certificate as Windows, On Windows
, we generate a certificate and shaare it for use in wsl:
dotnet dev-certs https -ep https.pfx -p $CREDENTIAL_PLACEHOLDER$ --trust
Then we open wsl, and Import this generated windows cert in our wsl:
dotnet dev-certs https --clean --import https.pfx --password $CREDENTIAL_PLACEHOLDER$
- https://github.com/dotnet/dotnet-docker/tree/main/samples ⭐⭐⭐
- https://github.com/twzhangyang/RestAirline/tree/master/docker-compose
- https://github.com/oskardudycz/EventSourcing.NetCore/docker-compose
- https://github.com/oskardudycz/EventSourcing.NetCore/Dockerfile
- https://github.com/WolfgangOfner/MicroserviceDemo/DockerFile
- https://github.com/WolfgangOfner/MicroserviceDemo/docker-compose
- https://github.com/madslundt/NetCoreMicroservicesSample/docker-compose
- https://github.com/madslundt/NetCoreMicroservicesSample/Dockerfile
- https://github.com/vietnam-devs/coolstore-microservices/deploys/dockers
- https://github.com/vietnam-devs/coolstore-microservices/docker-compose.yml
- https://github.com/vietnam-devs/coolstore-microservices/docker-compose.override
- https://github.com/vietnam-devs/coolstore-microservices/Dockerfile
- https://github.com/thangchung/clean-architecture-dotnet/Dockerfile
- https://github.com/thangchung/clean-architecture-dotnet/docker-compose.yml
- https://github.com/VasilisGaitanidis/master-containerized-microservices/docker-compose
- https://github.com/VasilisGaitanidis/master-containerized-microservices/Catalog/Dockerfile
- https://github.com/VasilisGaitanidis/master-containerized-microservices/docker-compose.override.yml
- Use
-f
to specify name and path of one or more Compose files - Ways to set environment variables in Compose
- Use an environment file
- Share Compose configurations between files and projects ⭐
- How to debug a .NET Core app in Docker with VSCode ⭐⭐
- Docker Tip #57: Using Build and Image in the Same Docker Compose Service ⭐
-
docker-compose
entrypoint
⭐ - Docker Compose keep container running ⭐⭐
- Interactive Shell Using Docker Compose ⭐
- Interactive shell using Docker Compose - StackOverflow
- Substitute for replacing evnironment only support from
.env file
substitute andshell substitute
for reading shell based environemnts - Substitute env files and repacing inner docker-compose files with
--env-file
and pass the file as an argument in the CLI, If the --env-file is not used in the command line, the .env file is loaded by default(docker compose --env-file ./config/.env.dev up)