Skip to content
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

docker-compose inspect #4155

Closed
pmihalcin opened this issue Nov 15, 2016 · 18 comments
Closed

docker-compose inspect #4155

pmihalcin opened this issue Nov 15, 2016 · 18 comments

Comments

@pmihalcin
Copy link

Hi all,
Are there any plans for docker-compose inspect command?
One could get e.g. exposed ports of given service

Thanks

@shin-
Copy link

shin- commented Nov 16, 2016

docker-compose ps already lets you see exposed ports.

@jsrun
Copy link

jsrun commented Jan 16, 2017

Hello friend, I made a module to solve this https://github.com/jsrun/docker-compose-remote-api

@ahilsend
Copy link

I agree! It would be very useful to have the commands available to docker itself also available to docker-compose.

@shin- shin- closed this as completed Aug 4, 2017
@awalterschulze
Copy link

Why was this closed?

@shin-
Copy link

shin- commented Aug 4, 2017

It won't be implemented. For the rare cases where it would be useful, people can use docker inspect instead.

@awalterschulze
Copy link

docker inspect only works if you setup your --project_name correctly.
But then I am also happy with docker inspect.

@elboletaire
Copy link

I don't get it... why is then docker-compose exec implemented? or docker-compose logs?

@RyanEwen
Copy link

+1

I would like to be able to write a script to check if a container is running but if the containers were started using compose and not named, then I don't know the name.

@dsaborg-waya
Copy link

It would be great to be able to inspect docker-compose containers so one does not need to know the project name beforehand.

@deeky666
Copy link

deeky666 commented Feb 1, 2018

For what it's worth: You can do something like (assuming the service to check is named foo)

docker inspect $(docker-compose ps -q foo)

Hope that helps.

@mihow
Copy link

mihow commented Mar 27, 2019

Is there a way to get the docker-compose project name programmatically? docker inspect isn't an option if a script can't determine the project name that compose generated.

For example, there is no consistent way to remove named volumes programmatically.

@larssb
Copy link

larssb commented Jan 14, 2020

@deeky666

I tried your suggestion and it works well for docker-compose.yml service definitions where one did not use --project-name. However, if that is what one did, it does not work as docker-compose ps -q _servicename_ returns nothing.

Is there anything one can do in the case described above?

Thank you

@deeky666
Copy link

@larssb I'm not sure if I get you right but maybe this helps?

docker inspect $(docker-compose --project-name PROJECT_NAME ps -q SERVICE_NAME)

@larssb
Copy link

larssb commented Jan 14, 2020

Hi @deeky666

Sure ... I might not have explained myself properly. If I for some reason, forgot, lost or for whatever reason, do not have the project name used. So I can't use the --project-name parameter to docker-compose ps ... is there then a way by which I can determine the project name that was used.

Thank you.

@rafipiccolo
Copy link

rafipiccolo commented Mar 6, 2021

If I do
docker-compose --project-name project up -d service

I get a container named : project_service_1

Then this will return data
Docker inspect $(docker ps -aq | grep _service_ )

Ez but shame.

@thenewguy
Copy link

I just happened across this issue trying to debug an odd problem with a container where I need to inspect one of the compose containers from inside a CI script. It seems bizarre not to include an easy to use docker-compose inspect option

@quant61
Copy link

quant61 commented Nov 1, 2021

You can inspect docker-compose containers like this:

docker inspect $(docker ps -f label=com.docker.compose.project.working_dir="$PWD" -f label=com.docker.compose.service=service_name --format '{{.ID}}')

If you want to use container id in scripts, you can do this:

CONTAINER_ID=$(docker ps -f label=com.docker.compose.project.working_dir="$PWD" -f label=com.docker.compose.service=service_name --format '{{.ID}}')

@thenewguy
Copy link

You can inspect docker-compose containers like this:

docker inspect $(docker ps -f label=com.docker.compose.project.working_dir="$PWD" -f label=com.docker.compose.service=service_name --format '{{.ID}}')

If you want to use container id in scripts, you can do this:

CONTAINER_ID=$(docker ps -f label=com.docker.compose.project.working_dir="$PWD" -f label=com.docker.compose.service=service_name --format '{{.ID}}')

Thank you for putting that together. I will make use of it.

It is still rather obscure and complicated for interacting with the cli by hand. It isn't viewable without scrolling on a 3000px wide monitor =P

docker-compose inspect db would be much easier to use

cdrage added a commit to cdrage/podman-desktop that referenced this issue Jul 24, 2023
### What does this PR do?

* Adds the inspect tab to Compose which is an array of "container
  inspect" from docker / podman.
* Inspect is JSON array of containers, see
  docker/compose#4155 for inspiration (they
  don't actually have a `compose inspect` command..)
* Adds tests

### Screenshot/screencast of this PR

<!-- Please include a screenshot or a screencast explaining what is doing this PR -->

### What issues does this PR fix or reference?

<!-- Please include any related issue from Podman Desktop repository (or from another issue tracker).
-->

Closes containers#3192

### How to test this PR?

1. Deploy a compose example
2. Click on the compose group
3. Select the inspect tab

<!-- Please explain steps to reproduce -->
cdrage added a commit to cdrage/podman-desktop that referenced this issue Jul 24, 2023
### What does this PR do?

* Adds the inspect tab to Compose which is an array of "container
  inspect" from docker / podman.
* Inspect is JSON array of containers, see
  docker/compose#4155 for inspiration (they
  don't actually have a `compose inspect` command..)
* Adds tests

### Screenshot/screencast of this PR

<!-- Please include a screenshot or a screencast explaining what is doing this PR -->

### What issues does this PR fix or reference?

<!-- Please include any related issue from Podman Desktop repository (or from another issue tracker).
-->

Closes containers#3192

### How to test this PR?

1. Deploy a compose example
2. Click on the compose group
3. Select the inspect tab

<!-- Please explain steps to reproduce -->

Signed-off-by: Charlie Drage <charlie@charliedrage.com>
cdrage added a commit to cdrage/podman-desktop that referenced this issue Jul 24, 2023
### What does this PR do?

* Adds the inspect tab to Compose which is an array of "container
  inspect" from docker / podman.
* Inspect is JSON array of containers, see
  docker/compose#4155 for inspiration (they
  don't actually have a `compose inspect` command..)
* Adds tests

### Screenshot/screencast of this PR

<!-- Please include a screenshot or a screencast explaining what is doing this PR -->

### What issues does this PR fix or reference?

<!-- Please include any related issue from Podman Desktop repository (or from another issue tracker).
-->

Closes containers#3192

### How to test this PR?

1. Deploy a compose example
2. Click on the compose group
3. Select the inspect tab

<!-- Please explain steps to reproduce -->

Signed-off-by: Charlie Drage <charlie@charliedrage.com>
cdrage added a commit to cdrage/podman-desktop that referenced this issue Jul 25, 2023
### What does this PR do?

* Adds the inspect tab to Compose which is an array of "container
  inspect" from docker / podman.
* Inspect is JSON array of containers, see
  docker/compose#4155 for inspiration (they
  don't actually have a `compose inspect` command..)
* Adds tests

### Screenshot/screencast of this PR

<!-- Please include a screenshot or a screencast explaining what is doing this PR -->

### What issues does this PR fix or reference?

<!-- Please include any related issue from Podman Desktop repository (or from another issue tracker).
-->

Closes containers#3192

### How to test this PR?

1. Deploy a compose example
2. Click on the compose group
3. Select the inspect tab

<!-- Please explain steps to reproduce -->

Signed-off-by: Charlie Drage <charlie@charliedrage.com>
cdrage added a commit to cdrage/podman-desktop that referenced this issue Jul 25, 2023
### What does this PR do?

* Adds the inspect tab to Compose which is an array of "container
  inspect" from docker / podman.
* Inspect is JSON array of containers, see
  docker/compose#4155 for inspiration (they
  don't actually have a `compose inspect` command..)
* Adds tests

### Screenshot/screencast of this PR

<!-- Please include a screenshot or a screencast explaining what is doing this PR -->

### What issues does this PR fix or reference?

<!-- Please include any related issue from Podman Desktop repository (or from another issue tracker).
-->

Closes containers#3192

### How to test this PR?

1. Deploy a compose example
2. Click on the compose group
3. Select the inspect tab

<!-- Please explain steps to reproduce -->

Signed-off-by: Charlie Drage <charlie@charliedrage.com>
cdrage added a commit to cdrage/podman-desktop that referenced this issue Jul 26, 2023
### What does this PR do?

* Adds the inspect tab to Compose which is an array of "container
  inspect" from docker / podman.
* Inspect is JSON array of containers, see
  docker/compose#4155 for inspiration (they
  don't actually have a `compose inspect` command..)
* Adds tests

### Screenshot/screencast of this PR

<!-- Please include a screenshot or a screencast explaining what is doing this PR -->

### What issues does this PR fix or reference?

<!-- Please include any related issue from Podman Desktop repository (or from another issue tracker).
-->

Closes containers#3192

### How to test this PR?

1. Deploy a compose example
2. Click on the compose group
3. Select the inspect tab

<!-- Please explain steps to reproduce -->

Signed-off-by: Charlie Drage <charlie@charliedrage.com>
cdrage added a commit to containers/podman-desktop that referenced this issue Jul 26, 2023
### What does this PR do?

* Adds the inspect tab to Compose which is an array of "container
  inspect" from docker / podman.
* Inspect is JSON array of containers, see
  docker/compose#4155 for inspiration (they
  don't actually have a `compose inspect` command..)
* Adds tests

### Screenshot/screencast of this PR

<!-- Please include a screenshot or a screencast explaining what is doing this PR -->

### What issues does this PR fix or reference?

<!-- Please include any related issue from Podman Desktop repository (or from another issue tracker).
-->

Closes #3192

### How to test this PR?

1. Deploy a compose example
2. Click on the compose group
3. Select the inspect tab

<!-- Please explain steps to reproduce -->

Signed-off-by: Charlie Drage <charlie@charliedrage.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests