You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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)
I am trying to pass extra_hosts argument to build without success.
Bellow is a simple way to reproduce this issue:
Without the extra_hosts argument, the code works fine.
With the extra_hosts argument I get:
Using the CLI also works:
The text was updated successfully, but these errors were encountered: