Tcb build: Error while fetching server API version

Hi,
today I always get an error when I try to build a custom image with a docker-compose file. It works without docker-compose and also worked last week. Going back and forward to an older/newer version of tcb didn’t help.
Since it worked last week, I did clean all my local docker images and updated some local tools, but I’d expect that this has no impact as tcb is container based.

The error log is:

2024-08-19 15:32:00,245 - torizon.tcbuilder.backend.deploy - INFO - Pulling OSTree with ref tcbuilder-20240819153154 from local archive repository...
2024-08-19 15:32:00,245 - torizon.tcbuilder.backend.deploy - INFO -   Commit checksum: 00b4f4d16384701b9e5b06c412555a4555c41ef62f8ba5de12703a7bce8572cd
2024-08-19 15:32:00,246 - torizon.tcbuilder.backend.deploy - INFO -   TorizonCore Version: 6.7.0+build.18-tcbuilder.20240819153159
2024-08-19 15:32:00,246 - torizon.tcbuilder.backend.deploy - INFO -   Default kernel arguments: quiet logo.nologo vt.global_cursor_default=0 plymouth.ignore-serial-consoles splash fbcon=map:3

2024-08-19 15:32:00,246 - torizon.tcbuilder.backend.ostree - DEBUG - Pulling from local repository /storage/ostree-archive commit checksum 00b4f4d16384701b9e5b06c412555a4555c41ef62f8ba5de12703a7bce8572cd
1050 metadata, 9446 content objects imported; 583.2 MB content written                                                                                                                                          
2024-08-19 15:32:08,358 - torizon.tcbuilder.backend.deploy - INFO - Pulling done.
2024-08-19 15:32:08,359 - torizon.tcbuilder.backend.deploy - INFO - Deploying OSTree with checksum 00b4f4d16384701b9e5b06c412555a4555c41ef62f8ba5de12703a7bce8572cd
2024-08-19 15:32:08,362 - torizon.tcbuilder.backend.deploy - DEBUG - Deploying revision 00b4f4d16384701b9e5b06c412555a4555c41ef62f8ba5de12703a7bce8572cd
2024-08-19 15:32:09,458 - torizon.tcbuilder.backend.deploy - INFO - Bootloader found in unpacked image: U-Boot
2024-08-19 15:32:09,459 - torizon.tcbuilder.backend.deploy - DEBUG - Write deployment for revision 00b4f4d16384701b9e5b06c412555a4555c41ef62f8ba5de12703a7bce8572cd
2024-08-19 15:32:10,336 - torizon.tcbuilder.backend.deploy - INFO - Deploying done.
2024-08-19 15:32:10,337 - torizon.tcbuilder.backend.deploy - INFO - Copy files not under OSTree control from original deployment.
2024-08-19 15:32:10,362 - torizon.tcbuilder.backend.deploy - INFO - Packing rootfs...
2024-08-19 15:32:10,367 - torizon.tcbuilder.backend.deploy - DEBUG - Running tar command: tar --xattrs '--xattrs-include=*' -cf /workdir/exivoip_0.0.2/torizon-core-docker-verdin-imx8mp.ota.tar -S -C /deploy -p .
2024-08-19 15:32:11,404 - torizon.tcbuilder.backend.deploy - DEBUG - Running compress command: zstd --rm /workdir/exivoip_0.0.2/torizon-core-docker-verdin-imx8mp.ota.tar
2024-08-19 15:32:16,447 - torizon.tcbuilder.backend.deploy - INFO - Packing rootfs done.
2024-08-19 15:32:16,447 - torizon.tcbuilder.backend.combine - INFO - Updating TorizonCore image in place.
2024-08-19 15:32:16,447 - torizon.tezi.image - DEBUG - No 'filelist' present in image configuration.
2024-08-19 15:32:16,447 - torizon.tezi.image - DEBUG - Reading json_data[key], value 'TorizonCore'
2024-08-19 15:32:16,447 - torizon.tezi.image - DEBUG - Writing json_data[key] = 'TorizonCore'
2024-08-19 15:32:16,448 - torizon.tezi.image - DEBUG - Reading json_data[key], value '6.7.0+build.18'
2024-08-19 15:32:16,448 - torizon.tezi.image - DEBUG - Writing json_data[key] = '6.7.0+build.18.modified'
2024-08-19 15:32:16,448 - torizon.tezi.image - DEBUG - Writing json_data[key] = '2024-08-19'
2024-08-19 15:32:16,548 - torizon.tezi.image - DEBUG - Reading json_data[key], value '6.7.0+build.18.modified'
2024-08-19 15:32:16,550 - torizon.tcbuilder.cli.build - INFO - Bundling images to directory bundle_20240819153216_550143.tmp
2024-08-19 15:32:16,550 - docker.utils.config - DEBUG - Trying paths: ['/root/.docker/config.json', '/root/.dockercfg']
2024-08-19 15:32:16,550 - docker.utils.config - DEBUG - No config file found
2024-08-19 15:32:16,551 - docker.utils.config - DEBUG - Trying paths: ['/root/.docker/config.json', '/root/.dockercfg']
2024-08-19 15:32:16,551 - docker.utils.config - DEBUG - No config file found
2024-08-19 15:32:16,848 - torizon.tcbuilder.cli.build - DEBUG - Removing temporary bundle directory bundle_20240819153216_550143.tmp
2024-08-19 15:32:16,848 - torizon.tcbuilder.cli.build - INFO - Removing output directory 'exivoip_0.0.2' due to build errors
2024-08-19 15:32:16,944 - root - CRITICAL - An unexpected Exception occurred. Please provide the following stack trace to
the Toradex TorizonCore support team:


2024-08-19 15:32:17,254 - root - ERROR - Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/urllib3/connectionpool.py", line 793, in urlopen
    response = self._make_request(
  File "/usr/local/lib/python3.9/dist-packages/urllib3/connectionpool.py", line 496, in _make_request
    conn.request(
  File "/usr/local/lib/python3.9/dist-packages/urllib3/connection.py", line 400, in request
    self.endheaders()
  File "/usr/lib/python3.9/http/client.py", line 1250, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.9/http/client.py", line 1010, in _send_output
    self.send(msg)
  File "/usr/lib/python3.9/http/client.py", line 950, in send
    self.connect()
  File "/usr/local/lib/python3.9/dist-packages/docker/transport/unixconn.py", line 27, in connect
    sock.connect(self.unix_socket)
PermissionError: [Errno 13] Permission denied

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 486, in send
    resp = conn.urlopen(
  File "/usr/local/lib/python3.9/dist-packages/urllib3/connectionpool.py", line 847, in urlopen
    retries = retries.increment(
  File "/usr/local/lib/python3.9/dist-packages/urllib3/util/retry.py", line 470, in increment
    raise reraise(type(error), error, _stacktrace)
  File "/usr/local/lib/python3.9/dist-packages/urllib3/util/util.py", line 38, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/lib/python3.9/dist-packages/urllib3/connectionpool.py", line 793, in urlopen
    response = self._make_request(
  File "/usr/local/lib/python3.9/dist-packages/urllib3/connectionpool.py", line 496, in _make_request
    conn.request(
  File "/usr/local/lib/python3.9/dist-packages/urllib3/connection.py", line 400, in request
    self.endheaders()
  File "/usr/lib/python3.9/http/client.py", line 1250, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.9/http/client.py", line 1010, in _send_output
    self.send(msg)
  File "/usr/lib/python3.9/http/client.py", line 950, in send
    self.connect()
  File "/usr/local/lib/python3.9/dist-packages/docker/transport/unixconn.py", line 27, in connect
    sock.connect(self.unix_socket)
urllib3.exceptions.ProtocolError: ('Connection aborted.', PermissionError(13, 'Permission denied'))

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 602, in get
    return self.request("GET", url, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/requests/sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.9/dist-packages/requests/sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.9/dist-packages/requests/adapters.py", line 501, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', PermissionError(13, 'Permission denied'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/builder/torizoncore-builder", line 222, in <module>
    mainargs.func(mainargs)
  File "/builder/tcbuilder/cli/build.py", line 592, in do_build
    build(args.config_fname, args.storage_directory,
  File "/builder/tcbuilder/cli/build.py", line 578, in build
    raise exc
  File "/builder/tcbuilder/cli/build.py", line 563, in build
    handle_output_section(
  File "/builder/tcbuilder/cli/build.py", line 308, in handle_output_section
    handle_easy_installer_output(tezi_props, storage_dir, union_params)
  File "/builder/tcbuilder/cli/build.py", line 380, in handle_easy_installer_output
    handle_bundle_output(
  File "/builder/tcbuilder/cli/build.py", line 436, in handle_bundle_output
    "host_workdir": common.get_host_workdir()[0],
  File "/builder/tcbuilder/backend/common.py", line 496, in get_host_workdir
    docker_client = DockerClient.from_env()
  File "/usr/local/lib/python3.9/dist-packages/docker/client.py", line 96, in from_env
    return cls(
  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: ('Connection aborted.', PermissionError(13, 'Permission denied'))

Hi, I’m the Toradex AI Assistant. I’m in early beta, and I would appreciate your feedback.
The Toradex Support team will follow up with you shortly!

Did you like my answer?

:+1: :-1:


The error you’re encountering indicates a permissions issue with Docker, specifically when trying to connect to the Docker daemon. This is evident from the PermissionError: [Errno 13] Permission denied part of the traceback. Here are a few steps you can take to troubleshoot and potentially resolve this issue:

  1. Docker Group Membership: Ensure your user is a member of the docker group. You can add your user to the docker group with the command sudo usermod -aG docker $USER. Remember to log out and back in for this change to take effect.

  2. Docker Daemon Running: Verify that the Docker daemon is running. You can check this with sudo systemctl status docker or by trying to run a simple Docker command like docker info. If it’s not running, you can start it with sudo systemctl start docker.

  3. Docker Socket Permissions: The error could be due to incorrect permissions on the Docker socket, usually located at /var/run/docker.sock. The Docker socket should generally be owned by root and the docker group with permissions set to 660. You can check this with ls -l /var/run/docker.sock and adjust the permissions if necessary with sudo chown root:docker /var/run/docker.sock and sudo chmod 660 /var/run/docker.sock.

  4. Using Docker Without Sudo: If you’re trying to run Docker commands without sudo, ensure that the previous steps have been correctly implemented. If you’ve just added your user to the docker group, remember that you need to log out and log back in for the group change to take effect.

  5. SELinux or AppArmor: If you’re running SELinux or AppArmor, they might be interfering with Docker’s permissions. You can temporarily disable these security modules to see if they are the cause of the issue. For SELinux, you can set it to permissive mode with sudo setenforce 0, and for AppArmor, you can disable it for Docker with sudo aa-disable docker.

If after following these steps you’re still facing issues, it might be helpful to provide more details about your environment, such as the operating system and Docker version, for further troubleshooting.

Best regards,
Toradex AI Assistant

Please, also check if these links can help you solve your problem:

How to Autorun Application at the Start up in Linux | Toradex Developer Center.

That all looks ok.

I am using:

  • Debian Testing
  • docker 26.1.4+dfsg1
  • torizoncore-builder 3.10.0

Hi @Urs ,

From the provided logs, TCB (more precisely, docker-py in it) cannot access /var/run/docker.sock on your host machine due to a permission error, as pointed out by the AI-generated answer.

Aside from the suggestions given by the AI (all of them are valid), can you manually get an image with the docker pull command on your host computer without any issues?

You said you updated some local tools. Does that include Docker Engine, or any software that could affect it?

Is the DOCKER_HOST environment variable set? The value of this variable affects how Docker behaves and on a ‘usual’ Docker setup it doesn’t need to be set.

And just to be sure, are you initializing TCB with the setup script (tcb-env-setup.sh) or in a different way?

Best regards,
Lucas Akira

Many thanks @lucas_a.tx.

DOCKER_HOST was set to unix:///run/user/1001/podman/podman.sock. Removing podman and unsetting DOCKER_HOST resolved the issue.

Glad I was able to help!

Best regards,
Lucas Akira