New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make start and restart accept commands, along with -i and -t options #1437
Comments
|
At the moment, containers or single-process units. You can't do this with docker in its current state. In the meantime, If you really must, you can use |
|
Thanks for the workaround, but I'm confused. Assuming a stopped docker run -i -t base /bin/bash |
|
Because right now, a container is defined by its process. If you change the process, you change container. If you want to start a new process, you have to use 'run'. |
|
Is it necessary to do the administration of the database inside the container? Would it make sense to connect to the database in the container as though it were a remote database |
|
If you're talking about a database with a remote administration tool, And one of the things I like about containers is that, if my container |
Try the Dockerfile instruction ADD
I think this is missing some of the opportunities Docker is providing. Doesn't the incremental snapshots of AUFS reduce how long it takes to make tweaks to a Dockerfile? I'd rather update a git reference and rebuild and relaunch.
You're right, it doesn't always "make sense to connect to the database in the container" with a remote administration tool.
I do not represent dotcloud or docker, and I hope you do not take my questions as advice. I am learning about docker and am wanting to learn more about its use cases. |
|
default datastore uses files
I'd rather not keep my usernames/passwords/account details outside of
They're valid points, and I appreciate their being raised. I just feel |
|
In a future version of docker we will introduce a I'm going to close this issue since it suggests a slightly different solution (changing the behavior of |
|
Sorry, on my phone right now or I'd check myself; do we already have a FIXME in the code for adding this separate exec primitive? |
|
@shykes Is the |
|
Not yet, we are still finishing up the final changes for docker exec |
|
I'm not sure why this was closed. Even though |
|
I am not sure why this was closed as "docker exec" does not solve the main issue here. There can be a host of different reasons an existing container may not come up with the default entrypoint/CMD command, therefore no running container exists to run "docker exec". This means that right now the only way to fix a broken container in these situations is simply to delete the container and start a new one with "docker run", not the ideal sittuation. Personally it would be nice to be able to override the entrypoint/CMD of an existing docker container with "docker start" (or at least CMD if anything). |
|
@ByteFlinger one option is to make the main process (as denoted by the CMD/ENTRYPOINT) be a, sort of, dummy process (e.g. just sleep forever) and then use "docker exec" to start up any additional process you want. Granted you're not specifying the process on the "docker start" but I think you'll end up with the same net result. |
|
But after you have created the container and it won't come up for whatever reason so that as soon as it comes up it goes down again, how will you change main process? |
|
you're right that its a totally different flow and way to work. And you need to make that kind of choice up-front, its not the kind of thing you can change once you've create an image/container with a CMD that runs something real. I was just looking for options given today's design. |
No, "run" starts a new container, with a new filesystem and different data to the existing container. If you want to start a command to do something with data in an existing container, you are plain out of luck, if for some reason you cant start it. And dont say "oooh containers should be ephemeral and not contain any meaningful data above the base image" - if that was the case then --rm would be the default, and there would be no concept of "stopped" containers, they would just be blown away when they stop, because after all, the cannot contain anything useful. If they do contain something useful, then we should be able to interact with them in whatever way we want. This is a ridiculous and pointless limitation to Docker, than has no justification whatsoever. |
|
Brand new to the Docker toolset today, having lots of experience with virtualization and some with process isolation via cgroups, chroot and other systems - finally had a side project where I thought the dockerdockerdocker hype would make sense and I end up here after a matter of hours. At this stage it's quite possible for me (if ridiculously annoying) to either rm the container, and run a new one with a different --entrypoint - or to just start it and exec a different process into it - but my brain keeps desperately reaching for a way to to change the COMMAND and start -ia. The workflow gap makes no sense from the the outside - I think I'd really have to know something about how the initial command is injected into the container fs/metadata during build for this to be a defensible behavior at all. Totally awkward to use. |
|
This would be a good addition to have, useful for running containerized CLI tools, without having to create different docker instances for every run. |
|
+1 In the same boat as @clayg. |
+1 |
+1 |
|
FYI: #19746 |
|
+1 |
|
Useful workaround, for the case where you want to shell into a container and examine the contents, but it's running a command that crashes immediately (or you don't want to rerun for some reason): docker commit CONTAINERID my-broken-container
docker run -it my-broken-container /bin/bashSaves the current state, starts it up interactively and doesn't run its normal start command, so you can happily take a look around. You can |
|
+1 |
|
+1
That's only useful for a broken container where you want to permanently change the command. Not useful for the dozens of other reasons to temporarily or run once with another command. |
|
@pimterry this is very helpful, but does it means if there is a bug preventing a container from start, the only solution is commit a new version and ditch the old one? |
|
@hihell I'm not sure exactly what you mean, but I think the answer is generally yes: if you have a broken unstartable container, you're going to have to build a new one. Doing so on top as here though means that you don't lose any of the existing state when you 'ditch' it - there's no downside to this. This is really just for debugging runtime issues though - containers are disposable, and you shouldn't be depending on their state persisting long-term. If you have anything important in the container, it should live in a volume, so its lifetime can be separated from the container. Once you've worked out the actual bug, the 'right' thing to do generally is to ditch the container completely, create a brand new image that includs your bugfix, and start up a new container from scratch. |
|
@pimterry great, thank you! |
I would like to create an image that installs a database, with its CMD set to the command that runs said database.
Next, I'd like to restart the container based on said image, only this time I'd like to run a shell, or the database administrative tool, and manipulate the data in the database.
While "run" lets me specify a command, along with the -i and -t options needed to start the command in the foreground and make it accept input, I cannot start or restart a container with the same constraints. Additionally, I can't specify a different command when restarting a container.
This could be a partial solution for #1351. If I can create a container, then spin up a shell in that same container, I can run administrative tools associated with an app. Ideally #1351 wouldn't be fully discounted, but I wouldn't feel its lack nearly as acutely as I do because I can't spin up a container with a different command to modify its contents.
The text was updated successfully, but these errors were encountered: