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

Failure to get the container id #1918

Closed
adarnimrod opened this issue May 22, 2021 · 0 comments · Fixed by #1919
Closed

Failure to get the container id #1918

adarnimrod opened this issue May 22, 2021 · 0 comments · Fixed by #1919

Comments

@adarnimrod
Copy link
Contributor

With #1888 in place, there's a regression when running inside a container. There's an assumption in https://github.com/pre-commit/pre-commit/blob/master/pre_commit/languages/docker.py#L32 that the hostname is the container ID which is not always the case (it's easy enough to set a different hostname with docker run --hostname foo). It causes the docker inspect command that follows to fail. A more reliable way to get the container id is from /proc/1/cpuset or from the first line in /proc/1/cgroup which is already checked in _is_in_docker.

Thanks @asottile and @okainov for your work on #1387 and pre-commit in general.

adarnimrod added a commit to adarnimrod/pre-commit that referenced this issue May 22, 2021
The hostname is not always the container id. Get the container id from
/proc/1/cgroup. Fixes pre-commit#1918.
adarnimrod added a commit to adarnimrod/pre-commit that referenced this issue May 22, 2021
The hostname is not always the container id. Get the container id from
/proc/1/cgroup. Fixes pre-commit#1918.
adarnimrod added a commit to adarnimrod/pre-commit that referenced this issue May 27, 2021
The hostname is not always the container id. Get the container id from
/proc/1/cgroup. Fixes pre-commit#1918.
adarnimrod added a commit to adarnimrod/pre-commit that referenced this issue May 27, 2021
The hostname is not always the container id. Get the container id from
/proc/1/cgroup. Fixes pre-commit#1918.
adarnimrod added a commit to adarnimrod/pre-commit that referenced this issue May 27, 2021
The hostname is not always the container id. Get the container id from
/proc/1/cgroup. Fixes pre-commit#1918.
adarnimrod added a commit to adarnimrod/pre-commit that referenced this issue May 27, 2021
The hostname is not always the container id. Get the container id from
/proc/1/cgroup. Fixes pre-commit#1918.
adarnimrod added a commit to adarnimrod/pre-commit that referenced this issue Jun 2, 2021
The hostname is not always the container id. Get the container id from
/proc/1/cgroup. Fixes pre-commit#1918.
adarnimrod added a commit to adarnimrod/pre-commit that referenced this issue Jun 2, 2021
The hostname is not always the container id. Get the container id from
/proc/1/cgroup. Fixes pre-commit#1918.
adarnimrod added a commit to adarnimrod/pre-commit that referenced this issue Jun 2, 2021
The hostname is not always the container id. Get the container id from
/proc/1/cgroup. Fixes pre-commit#1918.
adarnimrod added a commit to adarnimrod/pre-commit that referenced this issue Jun 2, 2021
The hostname is not always the container id. Get the container id from
/proc/1/cgroup. Fixes pre-commit#1918.
adarnimrod added a commit to adarnimrod/pre-commit that referenced this issue Jun 10, 2021
The hostname is not always the container id. Get the container id from
/proc/1/cgroup. Fixes pre-commit#1918.
adarnimrod added a commit to adarnimrod/pre-commit that referenced this issue Jun 10, 2021
The hostname is not always the container id. Get the container id from
/proc/1/cgroup. Fixes pre-commit#1918.
adarnimrod added a commit to adarnimrod/pre-commit that referenced this issue Jun 10, 2021
The hostname is not always the container id. Get the container id from
/proc/1/cgroup. Fixes pre-commit#1918.
adarnimrod added a commit to adarnimrod/pre-commit that referenced this issue Jun 10, 2021
The hostname is not always the container id. Get the container id from
/proc/1/cgroup. Fixes pre-commit#1918.
adarnimrod added a commit to adarnimrod/pre-commit that referenced this issue Jun 10, 2021
The hostname is not always the container id. Get the container id from
/proc/1/cgroup. Fixes pre-commit#1918.
adarnimrod added a commit to adarnimrod/pre-commit that referenced this issue Jun 10, 2021
The hostname is not always the container id. Get the container id from
/proc/1/cgroup. Fixes pre-commit#1918.
adarnimrod added a commit to adarnimrod/pre-commit that referenced this issue Jun 13, 2021
The hostname is not always the container id. Get the container id from
/proc/1/cgroup. Fixes pre-commit#1918.
adarnimrod added a commit to adarnimrod/pre-commit that referenced this issue Jun 13, 2021
The hostname is not always the container id. Get the container id from
/proc/1/cgroup. Fixes pre-commit#1918.
adarnimrod added a commit to adarnimrod/pre-commit that referenced this issue Jun 13, 2021
The hostname is not always the container id. Get the container id from
/proc/1/cgroup. Fixes pre-commit#1918.
adarnimrod added a commit to adarnimrod/pre-commit that referenced this issue Jun 13, 2021
The hostname is not always the container id. Get the container id from
/proc/1/cgroup. Fixes pre-commit#1918.
adarnimrod added a commit to adarnimrod/pre-commit that referenced this issue Jun 23, 2021
The hostname is not always the container id. Get the container id from
/proc/1/cgroup. Fixes pre-commit#1918.
adarnimrod added a commit to adarnimrod/pre-commit that referenced this issue Jun 23, 2021
The hostname is not always the container id. Get the container id from
/proc/1/cgroup. Fixes pre-commit#1918.
adarnimrod added a commit to adarnimrod/pre-commit that referenced this issue Jun 23, 2021
The hostname is not always the container id. Get the container id from
/proc/1/cgroup. Fixes pre-commit#1918.
adarnimrod added a commit to adarnimrod/pre-commit that referenced this issue Jun 23, 2021
The hostname is not always the container id. Get the container id from
/proc/1/cgroup. Fixes pre-commit#1918.
asottile pushed a commit to adarnimrod/pre-commit that referenced this issue Jul 3, 2021
The hostname is not always the container id. Get the container id from
/proc/1/cgroup. Fixes pre-commit#1918.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

2 participants