Lockbox creation failure with an 404 client error

Hi, I am trying to create a lockbox with torizoncore builder tool using ubuntu v.22 terminal (WSL2 in windows 11). I have used the torizoncore builder to build production images with tcbuild.yaml without any issues but when I tried to run command torizoncore-builder platform lockbox --credentials credentials.zip Offline_Update_test_1, it first give me docker daemon connection (tcp://127.0.0.1:22376) refused errors. I tried to restart docker daemon with sudo dockerd -H unix:///var/run/docker.sock -H tcp://127.0.0.1:22376 to enable the liston on the requested connection, but it doesn’t resolve the bug and gives me a 404 not found error.

The detailed error log is attached below:

=>> Handle director-repository metadata
Fetching ‘Offline_Update_test_1.json’
Fetching ‘offline-snapshot.json’
Fetching ‘1.root.json’
Fetching ‘2.root.json’
Fetching ‘3.root.json’
Fetching ‘3.root.json’ (version not available, stopping)

=>> Handle image-repository metadata
Fetching ‘snapshot.json’
Fetching ‘tdx-quarterly.json’
Fetching ‘tdx-monthly.json’
Fetching ‘targets.json’
Fetching ‘tdx-nightly.json’
Fetching ‘tdx-lts.json’
Fetching ‘tdx-containers.json’
Fetching ‘1.root.json’

=>> Process metadata
Loading offline-update targets metadata from ‘update/metadata/director/Offline_Update_test_1.json’
Loading offline-update snapshot metadata from update/metadata/director/offline-snapshot.json
Offline-update metadata passed basic validation
Loading image-repo targets metadata from ‘update/metadata/image-repo/targets.json’
Loading image-repo delegated targets metadata from ‘update/metadata/image-repo/tdx-nightly.json’
Loading image-repo delegated targets metadata from ‘update/metadata/image-repo/tdx-monthly.json’
Loading image-repo delegated targets metadata from ‘update/metadata/image-repo/tdx-quarterly.json’
Loading image-repo delegated targets metadata from ‘update/metadata/image-repo/tdx-lts.json’
Loading image-repo delegated targets metadata from ‘update/metadata/image-repo/tdx-containers.json’

=>> Handle Uptane targets
Fetching docker-compose target ‘nabit_os.lock.yml-0.1’
Fetching target ‘nabit_os.lock.yml-0.1’ from ‘https://api.torizon.io/repo/api/v1/user_repo/targets/nabit_os.lock.yml-0.1’…
Uptane info: target ‘nabit_os.lock.yml’, version: ‘0.1’

Fetching manifests for torizon/weston-vivante@sha256:b39bd723e554a95522bd6774796d6af7cac7cf4960e1c142b9a6f45e62691f45…
Saving manifest of torizon/weston-vivante [None]

Fetching manifests for cifengfang/cxldnabit-release@sha256:68377c13050f5fe2b20959534e5dc6639431e070bdbac875bfef1310705727f2…
Saving manifest of cifengfang/cxldnabit-release [None]

Fetching manifests for therndgroup/kiosk-mode-browser-vivante-cog@sha256:29659a376ad6647c8ee903cb2f2cf8a84f3890a1f68e95632e084e6723cbe2bf…
Saving manifest of therndgroup/kiosk-mode-browser-vivante-cog [None]

=> Digests selected per image:
torizon/weston-vivante@sha256:b39bd723e554a95522bd6774796d6af7cac7cf4960e1c142b9a6f45e62691f45, platform ‘None’:

  • sha256:b39bd723e554a95522bd6774796d6af7cac7cf4960e1c142b9a6f45e62691f45 [None]
    therndgroup/kiosk-mode-browser-vivante-cog@sha256:29659a376ad6647c8ee903cb2f2cf8a84f3890a1f68e95632e084e6723cbe2bf, platform ‘None’:
  • sha256:29659a376ad6647c8ee903cb2f2cf8a84f3890a1f68e95632e084e6723cbe2bf [None]
    cifengfang/cxldnabit-release@sha256:68377c13050f5fe2b20959534e5dc6639431e070bdbac875bfef1310705727f2, platform ‘None’:
  • sha256:68377c13050f5fe2b20959534e5dc6639431e070bdbac875bfef1310705727f2 [None]

=> Unique images selected:

  • cifengfang/cxldnabit-release@sha256:68377c13050f5fe2b20959534e5dc6639431e070bdbac875bfef1310705727f2
  • therndgroup/kiosk-mode-browser-vivante-cog@sha256:29659a376ad6647c8ee903cb2f2cf8a84f3890a1f68e95632e084e6723cbe2bf
  • torizon/weston-vivante@sha256:b39bd723e554a95522bd6774796d6af7cac7cf4960e1c142b9a6f45e62691f45

Starting DIND container
Using Docker host “tcp://127.0.0.1:22376”
Connecting to Docker Daemon at “tcp://127.0.0.1:22376”
Stopping DIND container
Removing output directory ‘update/’ due to errors
An unexpected Exception occured. Please provide the following stack trace to
the Toradex TorizonCore support team:

Traceback (most recent call last):
File “/usr/local/lib/python3.9/dist-packages/urllib3/connection.py”, line 174, in _new_conn
conn = connection.create_connection(
File “/usr/local/lib/python3.9/dist-packages/urllib3/util/connection.py”, line 95, in create_connection
raise err
File “/usr/local/lib/python3.9/dist-packages/urllib3/util/connection.py”, line 85, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/local/lib/python3.9/dist-packages/urllib3/connectionpool.py”, line 703, in urlopen
httplib_response = self._make_request(
File “/usr/local/lib/python3.9/dist-packages/urllib3/connectionpool.py”, line 386, in _make_request
self._validate_conn(conn)
File “/usr/local/lib/python3.9/dist-packages/urllib3/connectionpool.py”, line 1042, in _validate_conn
conn.connect()
File “/usr/local/lib/python3.9/dist-packages/urllib3/connection.py”, line 358, in connect
self.sock = conn = self._new_conn()
File “/usr/local/lib/python3.9/dist-packages/urllib3/connection.py”, line 186, in _new_conn
raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x7fda390fd5b0>: Failed to establish a new connection: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/local/lib/python3.9/dist-packages/requests/adapters.py”, line 489, in send
resp = conn.urlopen(
File “/usr/local/lib/python3.9/dist-packages/urllib3/connectionpool.py”, line 787, in urlopen
retries = retries.increment(
File “/usr/local/lib/python3.9/dist-packages/urllib3/util/retry.py”, line 592, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host=‘127.0.0.1’, port=22376): Max retries exceeded with url: /version (Caused by NewConnectionError(‘<urllib3.connection.HTTPSConnection object at 0x7fda390fd5b0>: Failed to establish a new connection: [Errno 111] Connection refused’))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/local/lib/python3.9/dist-packages/docker/api/client.py”, line 214, in _retrieve_server_version
return self.version(api_version=False)[“ApiVersion”]
File “/usr/local/lib/python3.9/dist-packages/docker/api/daemon.py”, line 181, in version
return self._result(self._get(url), json=True)
File “/usr/local/lib/python3.9/dist-packages/docker/utils/decorators.py”, line 46, in inner
return f(self, *args, **kwargs)
File “/usr/local/lib/python3.9/dist-packages/docker/api/client.py”, line 237, in _get
return self.get(url, **self._set_request_timeout(kwargs))
File “/usr/local/lib/python3.9/dist-packages/requests/sessions.py”, line 600, in get
return self.request(“GET”, url, **kwargs)
File “/usr/local/lib/python3.9/dist-packages/requests/sessions.py”, line 587, in request
resp = self.send(prep, **send_kwargs)
File “/usr/local/lib/python3.9/dist-packages/requests/sessions.py”, line 701, in send
r = adapter.send(request, **kwargs)
File “/usr/local/lib/python3.9/dist-packages/requests/adapters.py”, line 565, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host=‘127.0.0.1’, port=22376): Max retries exceeded with url: /version (Caused by NewConnectionError(‘<urllib3.connection.HTTPSConnection object at 0x7fda390fd5b0>: Failed to establish a new connection: [Errno 111] Connection refused’))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/builder/tcbuilder/backend/platform.py”, line 591, in build_docker_tarballs
dind_client = manager.get_client()
File “/builder/tcbuilder/backend/bundle.py”, line 305, in get_client
dind_client = docker.DockerClient(base_url=self.docker_host, tls=tls_config)
File “/usr/local/lib/python3.9/dist-packages/docker/client.py”, line 45, in init
self.api = APIClient(*args, **kwargs)
File “/usr/local/lib/python3.9/dist-packages/docker/api/client.py”, line 197, in init
self._version = self._retrieve_server_version()
File “/usr/local/lib/python3.9/dist-packages/docker/api/client.py”, line 221, in _retrieve_server_version
raise DockerException(
docker.errors.DockerException: Error while fetching server API version: HTTPSConnectionPool(host=‘127.0.0.1’, port=22376): Max retries exceeded with url: /version (Caused by NewConnectionError(‘<urllib3.connection.HTTPSConnection object at 0x7fda390fd5b0>: Failed to establish a new connection: [Errno 111] Connection refused’))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/local/lib/python3.9/dist-packages/docker/api/client.py”, line 268, in _raise_for_status
response.raise_for_status()
File “/usr/local/lib/python3.9/dist-packages/requests/models.py”, line 1021, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: http+docker://localhost/v1.41/containers/12c7570a5e1c8e9226a06e6e7f48499fb0c09da067cd4eecd7c8744b412a82c6/stop

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/builder/torizoncore-builder”, line 217, in
mainargs.func(mainargs)
File “/builder/tcbuilder/cli/platform.py”, line 308, in do_platform_lockbox
platform_lockbox(
File “/builder/tcbuilder/cli/platform.py”, line 296, in platform_lockbox
raise exc
File “/builder/tcbuilder/cli/platform.py”, line 276, in platform_lockbox
fetch_offupdt_targets(
File “/builder/tcbuilder/cli/platform.py”, line 187, in fetch_offupdt_targets
platform.fetch_compose_target(**params)
File “/builder/tcbuilder/backend/platform.py”, line 701, in fetch_compose_target
build_docker_tarballs(
File “/builder/tcbuilder/backend/platform.py”, line 649, in build_docker_tarballs
manager.stop()
File “/builder/tcbuilder/backend/bundle.py”, line 279, in stop
self.dind_container.stop()
File “/usr/local/lib/python3.9/dist-packages/docker/models/containers.py”, line 436, in stop
return self.client.api.stop(self.id, **kwargs)
File “/usr/local/lib/python3.9/dist-packages/docker/utils/decorators.py”, line 19, in wrapped
return f(self, resource_id, *args, **kwargs)
File “/usr/local/lib/python3.9/dist-packages/docker/api/container.py”, line 1170, in stop
self._raise_for_status(res)
File “/usr/local/lib/python3.9/dist-packages/docker/api/client.py”, line 270, in _raise_for_status
raise create_api_error_from_http_exception(e)
File “/usr/local/lib/python3.9/dist-packages/docker/errors.py”, line 31, in create_api_error_from_http_exception
raise cls(e, response=response, explanation=explanation)
docker.errors.NotFound: 404 Client Error for http+docker://localhost/v1.41/containers/12c7570a5e1c8e9226a06e6e7f48499fb0c09da067cd4eecd7c8744b412a82c6/stop: Not Found (“No such container: 12c7570a5e1c8e9226a06e6e7f48499fb0c09da067cd4eecd7c8744b412a82c6”)

Greetings @cifengfang,

I was able to reproduce this issue on my setup as well. It seems there’s a bug with the lockbox command when running on Windows/WSL machines specifically. I’ll report this bug to our team.

For the time being try the following workaround. Run the setup script again like so:

source tcb-env-setup.sh -- --network=host

Then try running the lockbox command again with TorizonCore Builder. This workaround allowed me to create a Lockbox on my own Windows/WSL machine.

Best Regards,
Jeremias

Thanks, @jeremias.tx. Reloading the torizoncore builder tool with source tcb-env-setup.sh -- --network=host resolved the issue.