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

Add podman compatibility #193

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions exegol/config/ConstantConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class ConstantConfig:
DOCKER_HUB: str = "hub.docker.com" # Don't handle docker login operations
DOCKER_REGISTRY: str = "registry-1.docker.io" # Don't handle docker login operations
IMAGE_NAME: str = "nwodtuhs/exegol"
IMAGE_FULL_NAME: str = "docker.io/nwodtuhs/exegol"
GITHUB_REPO: str = "ThePorgs/Exegol"
# Docker volume names (no docker volume used at this moment)
# Resources repository
Expand Down
11 changes: 7 additions & 4 deletions exegol/model/ExegolImage.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def __initFromDockerImage(self):
self.__name = ""
for repo_tag in self.__image.attrs["RepoTags"]:
repo, name = repo_tag.split(':')
if not repo.startswith(ConstantConfig.IMAGE_NAME):
if not repo.startswith(ConstantConfig.IMAGE_NAME) and not repo.startswith(ConstantConfig.IMAGE_FULL_NAME):
# Ignoring external images (set container using external image as outdated)
continue
version_parsed = MetaImages.tagNameParsing(name)
Expand Down Expand Up @@ -534,10 +534,13 @@ def __setDigest(self, digest: Optional[str]):
def __parseDigest(docker_image: Image) -> str:
"""Parse the remote image digest ID.
Return digest id from the docker object."""

"""Unlike Docker, podman often fill RepoDigests with multiple values, we keep the last one which seems to match the digest attr"""
last_digest = ""
for digest_id in docker_image.attrs["RepoDigests"]:
if digest_id.startswith(ConstantConfig.IMAGE_NAME): # Find digest id from the right repository
return digest_id.split('@')[1]
return ""
if digest_id.startswith(ConstantConfig.IMAGE_NAME) or digest_id.startswith(ConstantConfig.IMAGE_FULL_NAME) : # Find digest id from the right repository
last_digest = digest_id.split('@')[1]
return last_digest

def getRemoteId(self) -> str:
"""Remote digest getter"""
Expand Down
11 changes: 8 additions & 3 deletions exegol/utils/DockerUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ def createContainer(cls, model: ExegolContainerTemplate, temporary: bool = False
"stdin_open": model.config.interactive,
"tty": model.config.tty,
"mounts": model.config.getVolumes(),
"working_dir": model.config.getWorkingDir()}
"working_dir": model.config.getWorkingDir(),
"security_opt" : ["label=disable"]
}
if temporary:
# Only the 'run' function support the "remove" parameter
docker_create_function = cls.__client.containers.run
Expand Down Expand Up @@ -341,9 +343,12 @@ def __listLocalImages(cls, tag: Optional[str] = None) -> List[Image]:
result = []
ids = set()
for img in images:
repoTaglist = [repo_tag.split(':')[0] for repo_tag in img.attrs.get("RepoTags", [])]
# len tags = 0 handle exegol <none> images (nightly image lost their tag after update)
if len(img.attrs.get('RepoTags', [])) == 0 or \
ConstantConfig.IMAGE_NAME in [repo_tag.split(':')[0] for repo_tag in img.attrs.get("RepoTags", [])]:
if len(img.attrs.get('RepoTags', [])) == 0 \
or ConstantConfig.IMAGE_NAME in repoTaglist \
or ConstantConfig.IMAGE_FULL_NAME in repoTaglist:

result.append(img)
ids.add(img.id)

Expand Down