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

socket.gethostname() method for python docker lib returns hostname() for old #209

Closed
Valleymu opened this issue Jan 20, 2025 · 1 comment

Comments

@Valleymu
Copy link

Valleymu commented Jan 20, 2025

I have this method running in docker container

import docker

def register_container():
    client = docker.from_env(version="auto", timeout=30)
    container = client.containers.get(socket.gethostname())

When watchtower updates my image and restarts container I get this error:

2025-01-20 01:24:48 docker.errors.NotFound: 404 Client Error for http+docker://localhost/v1.47/containers/4658ae62f206/json: Not Found ("No such container: 4658ae62f206")

4658ae62f206 is an old container id, looks like socket returns old hostname

Is there a way to fix it? I'm attempting to get container ID

After restart environment variable HOSTNAME is also old one

@kislyuk
Copy link
Owner

kislyuk commented Jan 20, 2025

Hi, I think this you are in the wrong project. I'm going to close this issue now as it does not refer to any functionality that this library supports.

@kislyuk kislyuk closed this as completed Jan 20, 2025
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

2 participants