#mounted dir not in container

1 messages · Page 1 of 1 (latest)

compact whale
#

Hello dagger team!

I'm not being able to mount a dir inside the container.
Code:

import sys
import uuid

import anyio
import dagger
from dagger import Config, Container


async def run():
    dagger_config: Config = dagger.Config(log_output=sys.stdout)

    async with dagger.Connection(dagger_config) as client:
        container: Container = client.container().from_('python:3.10')\
            .with_env_variable('BURST_CACHE', str(uuid.uuid4()))

        container = container.with_workdir('/src')
        container = container.with_mounted_directory('app', client.host().directory('app'))

        container = container.with_exec(['ls', '-l', '.'])
        container = container.with_exec(['ls', '-l', '/src/app'])

        tar = await container.export('./export.tar')

anyio.run(run)

I load the tarball and run it doing:
docker run -it IMAGEID /bin/bash
and then:

root@bb2143b8bccd:/src# ls -l
total 0

Nothing in there...

The results from the with_exec ls -l are:

#2 
#2 0.164 total 4
#2 0.164 drwxr-xr-x 1 root root 4096 Mar 29 18:00 app
#2 DONE 0.2s

#2 
#2 0.173 total 4
#2 0.173 -rw-r--r-- 1 root root   0 Mar 29 16:41 __init__.py
#2 0.173 -rw-r--r-- 1 root root 262 Mar 29 16:18 main.py
#2 DONE 0.5s

It seems the folder and files are there. But then when the container runs it can't find the code...

Am I missing something here? And excuse me in advance if im missing some 101 stuff here...

Thanks again!

lofty lantern
compact whale
#

oh yeah! thanks Kyle i'll try that right now

compact whale
#

this worked great

ruby cloak
ruby cloak
compact whale
#

Gracias @ruby cloak

#

This last 2 weeks I gathered several gotchas and I'm putting all together in some guides for the team. I'll share them with you in case they are helpful. Thanks again for the support