I have a docker compose that runs many containers including a container with .Net core code and a dd-agent container.
I have noticed that dd-agent container uses a volume and I need to access files in that volume using code running in the other container.
I have tried to use:
var path = System.Reflection.Assembly.GetExecutingAssembly().Location;
var root = Path.GetPathRoot(path);
var files = Directory.GetFiles(root, "*.log", SearchOption.AllDirectories);
but the files list doesn't contain the files I can see in volume when running something like:
docker run --rm -i -v=myvolume:/tmp/myvolume busybox find /tmp/myvolume
Any ideas on how I can get the volume files?
Docker-compose:
version: "3.7"
volumes:
logs:
services:
localstack:
image: localstack/localstack
container_name: localstack
environment:
- SERVICES=s3,dynamodb
- AWS_DEFAULT_REGION=eu-west-1
- HOSTNAME_EXTERNAL=localstack
- HOSTNAME=localstack
- AWS_ACCESS_KEY_ID=test
- AWS_SECRET_ACCESS_KEY=test
ports:
- "4572:4572"
- "4569:4569"
aws-cli:
container_name: aws-cli
image: mesosphere/aws-cli
volumes:
- ./../script:/script
environment:
- AWS_DEFAULT_REGION=eu-west-1
- AWS_SECRET_ACCESS_KEY=test
- AWS_ACCESS_KEY_ID=test
entrypoint: /script/aws.sh
depends_on:
- localstack
dd-agent:
container_name: dd-agent
image: datadog/agent:latest
ports:
- "8126:8126"
environment:
- DD_APM_ENV=test
- DD_API_KEY={}
- DD_PROCESS_AGENT_ENABLED=true
- DD_DOGSTATSD_NON_LOCAL_TRAFFIC=true
- DD_APM_ENABLED=true
- DD_APM_NON_LOCAL_TRAFFIC=true
- DD_LOG_LEVEL=info
- DD_HOSTNAME=datadoghq
volumes:
- logs:/var/log/datadog
myapi:
container_name: myapi
restart: unless-stopped
build:
target: final
args:
RELEASETYPE: "Debug"
context: ./../
dockerfile: path/Dockerfile
environment:
- ASPNETCORE_ENVIRONMENT=Development
- DD_AGENT_HOST=dd-agent
- DD_ENV=test
- DD_LOGS_INJECTION=true
- DD_SERVICE_NAME=test
- DD_TRACE_AGENT_PORT=8126
- DD_TRACE_AGENT_URL=http://dd-agent:8126
- DD_TRACE_DEBUG=true
- DD_TRACE_ENABLED=true
- DD_TRACE_LOG_PATH=/var/log/datadog/dotnet-profiler.log
- FLUENTD_PORT=24224
- FLUENTD_RETRIES=3
volumes:
- logs:/var/log/datadog
- type: bind
source: ../src
target: /src/src
ports:
- 1990:80
depends_on:
- aws-cli
docker runcommands note that Compose will rename things like volumes and networks so you'll need a command likedocker volume lsto find the actual volume name.