Comments (8)
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 xxxinto 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:8301so 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.
@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.
To me this should be solved by being able to use --name
... what is that status of that?
from registrator.
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.
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.
That sounds awesome. Looking forward to that system, so I have an excuse to pick up Go development again 👍
from registrator.
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.
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)
- Not able to get POD IP for registration in EKS
- unsupported protocol scheme ""
- Cannot unmarshal number into Go value of type string HOT 1
- Support for newer versions of Consul HOT 10
- Support for 3.x version of etcd HOT 2
- Dead link in website
- cannot connect to Docker endpoint
- Unregister on 'stop'
- Health checks with SERVICE_CHECK_SCRIPT doesn't work HOT 1
- Possible bug (or by-design behavior) of using IPv6 addresses to register TCP health check to `Consul`?
- http://gliderlabs.com/ is down HOT 1
- Image docker.io/gliderlabs/registrator:latest uses outdated schema1 manifest format HOT 2
- Require image for ARM64 architecture HOT 3
- gliderlabs.com is down HOT 1
- All service names start with sha265 when containers are started with the new compose-cli HOT 3
- Takeover the project HOT 7
- I would like to add support for excluding some containers
- Not an issues | Registrator Updated / Fork HOT 2
- Fork of this project and an open invitation to participate. HOT 1
- Registrator not picking the events everytime
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from registrator.