emacs-pe / docker-tramp.el

TRAMP integration for docker containers
340 stars 25 forks source link

Using on docker-compose containers? #16

Open dabro opened 7 years ago

dabro commented 7 years ago

How would you suggest best using or modifying this package to use containers that are managed by docker-compose, which move a lot of configuration/env/dependency settings to the docker-compose.yml file? There is of course docker-compose exec, whose big difference is the lack of -e and the default tty allocation. But you also have to account for the docker-compose options, like -p to specify a non-default docker-compose.yml file, and the difference between the docker name (eg dev_box_1) and the docker-compose service name (eg box):

Execute a command in a running container

Usage: exec [options] SERVICE COMMAND [ARGS...]

Options:
    -d                Detached mode: Run command in the background.
    --privileged      Give extended privileges to the process.
    -u, --user USER   Run the command as this user.
    -T                Disable pseudo-tty allocation. By default `docker-compose exec`
                      allocates a TTY.
    --index=index     index of the container if there are multiple
                      instances of a service [default: 1]

There's also docker-compose run:

Run a one-off command on a service.

For example:

    $ docker-compose run web python manage.py shell

By default, linked services will be started, unless they are already
running. If you do not want to start linked services, use
`docker-compose run --no-deps SERVICE COMMAND [ARGS...]`.

Usage: run [options] [-v VOLUME...] [-p PORT...] [-e KEY=VAL...] SERVICE [COMMAND] [ARGS...]

Options:
    -d                    Detached mode: Run container in the background, print
                          new container name.
    --name NAME           Assign a name to the container
    --entrypoint CMD      Override the entrypoint of the image.
    -e KEY=VAL            Set an environment variable (can be used multiple times)
    -u, --user=""         Run as specified username or uid
    --no-deps             Don't start linked services.
    --rm                  Remove container after run. Ignored in detached mode.
    -p, --publish=[]      Publish a container's port(s) to the host
    --service-ports       Run command with the service's ports enabled and mapped
                          to the host.
    -v, --volume=[]       Bind mount a volume (default [])
    -T                    Disable pseudo-tty allocation. By default `docker-compose run`
                          allocates a TTY.
    -w, --workdir=""      Working directory inside the container
olessavluk commented 6 years ago

What problem do you have with docker-compose? I am already using this library for the containers managed by compose, and it works just fine

Fuco1 commented 6 years ago

Maybe the confusion here is between the service name and the container name (as mentioned box vs dev_box_1). However this is not a problem and the package works no problem so long as the container name is used.

It would be nice to maybe map to the service name but then I call everything app so that would likely result in more confusion than good.

codeasone commented 4 years ago

If you always want names (rather than the container IDs) to appear in the completion list then (setq docker-tramp-use-names t)