Tilt: Exposed working directory doesn't get written to from built container

Created on 31 Jul 2019  路  7Comments  路  Source: tilt-dev/tilt

With normal docker/docker-compose if I copy a working directory and then write to that location from my running container, those writes are reflected in my local directory.

This doesn't seem to happen w/ Tilt which is shame b/c it helps with development quite a bit.

One simple example is having a Golang app that uses modules. Normally I could use a (blank) go.mod file and have it be written to with all the app's dependencies once the app and container has been built; the same with go.sum etc...

Is there a way we can have this same behavior w/ Tilt?

Example Dockerfile:

FROM golang:1.12.0

ENV GOWORKDIR /go/src/com/example/app

ENV GO111MODULE=on

COPY ./ $GOWORKDIR
WORKDIR $GOWORKDIR

ENTRYPOINT app

In my local directory that I copy from I have a go.mod that doesn't get written to.

invalid

All 7 comments

Thanks for the issue @ozburo. I assume you're talking about Volumes here right?

I recall we do _something_ off-label with DC Volumes, because of how Tilt's internals work, but I don't remember exactly what. I'll mark this issue as a feature request, and go dig a bit into our existing behavior to find out where we're at. More soon!

Thanks for taking a look at this @maiamcc :)

I assume you're talking about Volumes here right?

No, not in this particular instance. However, I haven't looked much into using Volumes yet so can't comment on whether that's related or a workaround etc.

...Oh, then I'm confused about what Docker Compose behavior you're talking about. Can you paste your docker-compose.yml?

You know what, I think I was mistaken! Yes I was using volumes in docker-compose -- I thought you meant using volumes in Kubernetes.

Here's my sample docker-compose.yaml:

version: '3'
services:
  app:
    build:
      context: ./
    container_name: my-app
    volumes:
      - .:/go/src/com/myapp
    ports:
      - 80:80

You know what, this could totally be user error on my part and not understanding Tilt/K8s properly.

For clarification, the above docker-compose.yaml _was_ how I used to develop before moving to Tilt, I am not using Tilt's docker-compose functionality (https://docs.tilt.dev/docker_compose.html) with that docker-compose file posted above but rather starting from scratch with a fresh Tiltfile that builds my Dockerfile (the one in my first post).

So maybe my issue is that I haven't created an exposed volume like we do w/ docker-compose? Or perhaps I should use a docker-compose file w/ Tilt to get this behavior instead?

Sorry for my confusion!

...oh! Yeah, that would do it :P

So Tilt has no way to mount volumes like Docker Compose does, i.e. you can make a change in the container and it propagates back to your local filesystem -- but other people have definitely requested it!

I'd recommend you give Tilt a shot with Docker Compose mode and see if that works for your use case -- and if not, give us a ping/file another issue and we'll look into adding something similar for k8s.

@ozburo I'm going to go ahead and close this ticket, but please reach out if you hit any trouble with Docker Compose, or if it doesn't suit your use case.

In the meantime, I opened #1956 for "support for volumes via k8s" -- definitely chime in over there if this is behavior you need on k8s.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nicks picture nicks  路  3Comments

david-martyn-ford picture david-martyn-ford  路  4Comments

majelbstoat picture majelbstoat  路  4Comments

qibinlou picture qibinlou  路  4Comments

bandrade picture bandrade  路  5Comments