Is it possible to add attach function to fig?
For example, Using command "fig attach appname" to enter the container which was created by fig. I think this may be helpful in some cases. Now I know that nsenter can attach a new bash shell on a running container, but I don't know if it's possible to intergrate it with fig. Thanks.
Need it too!
docker-enter (https://github.com/jpetazzo/nsenter/blob/master/docker-enter) is just a bash script.
I supposed you can base on that to write a fig-enter script.
Maybe it's more convenient to use alias below in your terminal.
alias attach='bash -c "nsenter --mount --uts --ipc --net --pid --target docker inspect --format \"{{.State.Pid}}\" \$0"'
Then you can use attach container_name to enter a container.
It shouldn't be too difficult to add this using dockerpty, which is what fig is using right now to handle fig run, I think.
@bcheng049 the docker-enter script also handles some edge-cases (e.g. If you're not using bash as your shell), and makes sure to set up the environment variables of the container and not your host environment. The alias you're suggesting, won't handle those.
This would be huge for my team also
@thaJeztah Yes, it is just a snippet to avoid inputing many commands without installing a script.
Just wanted to clear that up to prevent people trying to solve problems that are already solved in the docker-enter script. Adding this functionality to fig would be a nice addition though (still hoping Docker itself will support this natively).
In the short run, I'd really advice people that want to have it now to install jpetazzo's script. Installing it is just a one-liner as explained in the readme; https://github.com/jpetazzo/nsenter
After installing, entering a running container is just simply docker-enter [container-name]
There's two issues here: 1) being able to enter with nsenter and fiddle around with a running container, and 2) a way to get docker run web bash behavior but also bring up the entire stack not just direct links. The first is great for debugging and the second is great for development workflows with volumes mounted into containers. Just bringing up links is not enough for many stacks.
I think fig up -d, fig run solves 2, but I'm not really clear on why you'd need to bring up services if they aren't linked. A container doesn't need to be running to share volumes.
The set up I have in mind is proxy -> web -> db. I'd like to be able to bring this stack up, but develop in web using a bash prompt. I haven't found an easy to to do this, such that all the links work.
attach and interactive is very useful to debug the running software using tools like python pdb.
It's an essential feature to configure docker container. When this feature are release ?
I agree that fig attach and fig exec, analogous to their docker counterparts, would be good to have. Is anyone here asking for anything other than those?
It would be nice if attach was exposed in fig.yml, so that we could specify which one we want to attach to interactive tty on "fig up"
@aanand Any update on when this may be available?
this would be lovely!
I'm strongly against the idea of doing an interactive attach on fig up - it's overloading its purpose.
The correct way to bring up an interactive container with its dependencies is fig run. We just need to get port mapping implemented (see #485, which I'll get to soon).
Aanand, you said:
I agree that fig attach and fig exec, analogous to their docker counterparts, would be good to have. Is anyone here asking for anything other than those?
I believe just those two will make a lot of people happy.
I don't use fig scale and I'm not sure if you have considered how fig attach and fig exec would work with those. I suppose if I were to use fig scale I wouldn't care which container was used.
Will this issue address both fig attach and fig exec, or would it be better if a separate issue was logged?
oops, wrong key, sorry