Git Product home page Git Product logo

Comments (8)

progrium avatar progrium commented on June 7, 2024

If that's run on the same hosts, why not just docker ps for the name and
get the ID that way? docker ps -qf name= will get you the ID

On Wed, Dec 17, 2014 at 7:21 AM, Jean Mertz [email protected]
wrote:

While working with CoreOS, I ran into this issue
coreos/fleet#612 (comment) where fleetctl
destroy would not remove any stopped containers.

Later, I learned
coreos/fleet#612 (comment) the
cause for this:

Containers are handled quite fine with fleet. It's just edge cases like
--name that causes you to do some workarounds because of the way it's
handled in Dockerland.

I already replied
coreos/fleet#612 (comment) to
this with questions on how to properly stop/destroy a container.

However, I have a feeling I should be able to do this with Registrator,
but haven't been able to do so yet.

What I'm running into is that I need to convert this:

ExecStart=/usr/bin/docker run --name xxx ...."
ExecStop=/usr/bin/docker stop xxx

into something where ExecStop can use the started container ID to stop
it, instead of using --name value.

Using jq http://stedolan.github.io/jq/ (which is also awesome), I could
parse the Consul data stored by Registrator like this:

$ curl -s $COREOS_PRIVATE_IPV4:8500/v1/catalog/service/consul | jq '.[0]'

{
"Node": "portal-2",
"Address": "172.17.8.102",
"ServiceID": "consul",
"ServiceName": "consul",
"ServiceTags": [],
"ServicePort": 8300
}

But this doesn't give me the container ID. I can understand that this
doesn't really mean anything for cross-host or public, but the data is
apparently already "shown" in the logs:

2014/12/17 08:14:56 registrator: added: 24f4ffb25f6a portal-3:consul:53:udp
2014/12/17 08:14:56 registrator: added: 24f4ffb25f6a portal-3:consul:8300
2014/12/17 08:14:56 registrator: added: 24f4ffb25f6a portal-3:consul:8301

so having this in Registrator would be really nice.

Having said that, if you - as an expert on Docker/CoreOS/discovery - have
any insights into this, and perhaps a better way to solve this issue, then
I'm all ears :) [image: 👍]


Reply to this email directly or view it on GitHub
https://github.com/progrium/registrator/issues/75.

Jeff Lindsay
http://progrium.com

from registrator.

JeanMertz avatar JeanMertz commented on June 7, 2024

@progrium I don't have the name (because I purposely run docker run without --name).

Since my last post, I've been working on solving it this way:

# ex. %p = redis, %i = development

ExecStart=/usr/bin/docker run --cidfile /tmp/%p-%i.cid %p
ExecStartPost=/usr/bin/curl -X PUT -d $(cat /tmp/%p-%i.cid) http://${COREOS_PRIVATE_IPV4}:8500/v1/kv/%p/%i/cid
ExecStartPost=/usr/bin/rm -f /tmp/%p-%i.cid

ExecStop=/usr/bin/docker stop $(curl http://${COREOS_PRIVATE_IPV4}:8500/v1/kv/%p/%i/cid | xargs docker inspect --format '{{.Name}}')

Any thoughts on this?

This is untested yet, as I've just finished writing it, but it should get the job done. Having the CID stored in the Registrator data would make things easier though.

from registrator.

progrium avatar progrium commented on June 7, 2024

To me this should be solved by being able to use --name ... what is that status of that?

from registrator.

JeanMertz avatar JeanMertz commented on June 7, 2024

what do you mean with "the status of that"?

Using --name is technically possible, but I don't name my docker instances, because I want them to be unique, and spinning up multiple instances shouldn't give me duplicate naming errors in Docker (instead, if no duplication of a running Docker image is allowed, I want to handle this myself).

I am currently running my Docker instances using this gist: https://gist.github.com/JeanMertz/455b8d4a33e0c9099d22

It gets the job done, but since I've already got Registrator running, I'd much rather have Registrator show me the image ID as well, it would save a lot of time and work, and would be easier to query using Registrator.

from registrator.

progrium avatar progrium commented on June 7, 2024

Hmm... sounds like a potential module for our new extension system in the works. I'll leave this open for now to revisit later.

from registrator.

JeanMertz avatar JeanMertz commented on June 7, 2024

That sounds awesome. Looking forward to that system, so I have an excuse to pick up Go development again 👍

from registrator.

progrium avatar progrium commented on June 7, 2024

I think we've decided the feature request here is out of the scope of registrator so we're going to close this issue.

from registrator.

soumyadipDe avatar soumyadipDe commented on June 7, 2024

Any idea how we can achieve this? Can we make registrator read the $HOSTNAME variable inside container where the container ID is stored? I tried setting this $HOSTNAME as $SERVICE_HOSTNAME or something in docker-compose but could not make it work.

from registrator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.