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

ImagesManager.build extra_hosts argument not working #398

Open
irigon opened this issue Jun 14, 2024 · 1 comment
Open

ImagesManager.build extra_hosts argument not working #398

irigon opened this issue Jun 14, 2024 · 1 comment

Comments

@irigon
Copy link

irigon commented Jun 14, 2024

I am trying to pass extra_hosts argument to build without success.

Bellow is a simple way to reproduce this issue:

import podman
from podman import PodmanClient

CONTAINER_SOCKET_PATH = "unix:///var/run/docker.sock"


# Initialize the Podman client
client = PodmanClient(base_url=CONTAINER_SOCKET_PATH)

# Specify the path to your Dockerfile and context directory
dockerfile_path = "Dockerfile"
# context_path = '/path/to/your/context'

# Build the image
image, logs = client.images.build(
    path="/private/tmp/tmp",
    dockerfile=dockerfile_path,
    tag="myimage:latest",  # Replace with your desired image tag
    rm=True,  # Optional: Remove intermediate containers after build
    extra_hosts={"example.com": "192.168.1.1"},
)

# Optionally, you can inspect the built image
print(f"Built image ID: {image.id}")

Without the extra_hosts argument, the code works fine.
With the extra_hosts argument I get:

podman.errors.exceptions.APIError: 400 Client Error: Bad Request (failed to parse query parameter 'extrahosts': "{\"repo\": \"147.204.144.142\"}": json: cannot unmarshal object into Go value of type []string)

Using the CLI also works:

podman buildx build --add-host=repo:147.204.144.142 --build-arg PACKAGE=mypackage  --platform linux/amd64  -t s3loadtest .
@jwhonce
Copy link
Member

jwhonce commented Jul 8, 2024

See also containers/podman#17292

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