I am running a Dockerfile that (is supposed to) run a docker-compose.yml file for a different package, but currently returns an error.
The command
docker-compose -f /home/kasm-default-profile/Project-main/docker-compose.yml up -d --build
fails because the Docker client cannot connect to the Docker daemon.
This is my Dockerfile:
FROM kasmweb/core-ubuntu-jammy:1.15.0
USER root
ENV HOME /home/kasm-default-profile
ENV STARTUPDIR /dockerstartup
ENV INST_SCRIPTS $STARTUPDIR/install
WORKDIR $HOME
######### Customize Container Here ###########
#get updates, install python 3.8, pip, unzip and docker's prerequisites && systemd installed#
RUN apt-get update
RUN apt-get upgrade -y
RUN apt-get install software-properties-common
RUN apt-add-repository ppa:deadsnakes/ppa -y
RUN apt-get update
RUN apt-get install -y python3.10 python3-pip ca-certificates curl unzip systemd
RUN install -m 0755 -d /etc/apt/keyrings
RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
RUN chmod a+r /etc/apt/keyrings/docker.asc
#run the command to add the repo to the Apt sources#
RUN echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
RUN sudo apt-get update
#installs docker#
RUN sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
RUN sudo apt-get update
RUN sudo service docker start
RUN sudo /etc/init.d/docker start
#takes the Project zip, unzips it in container and runs docker compose#
COPY ./Project-main.zip /home/kasm-default-profile/
RUN unzip /home/kasm-default-profile/Project-main.zip
RUN rm /home/kasm-default-profile/Project-main.zip
RUN sudo apt-get install docker-compose -y
RUN docker-compose -f /home/kasm-default-profile/Project-main/docker-compose.yml up -d --build
######### End Customizations ###########
RUN chown 1000:0 $HOME
RUN $STARTUPDIR/set_user_permission.sh $HOME
ENV HOME /home/kasm-user
WORKDIR $HOME
RUN mkdir -p $HOME && chown -R 1000:0 $HOME
USER 1000
And this is the full error it returns:
> [22/29] RUN docker-compose -f /home/kasm-default-profile/Project-main/docker-compose.yml up -d --build:
0.525 Traceback (most recent call last):
0.525 File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 700, in urlopen
0.525 httplib_response = self._make_request(
0.525 File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 395, in _make_request
0.525 conn.request(method, url, **httplib_request_kw)
0.525 File "/usr/lib/python3.10/http/client.py", line 1283, in request
0.525 self._send_request(method, url, body, headers, encode_chunked)
0.525 File "/usr/lib/python3.10/http/client.py", line 1329, in _send_request
0.525 self.endheaders(body, encode_chunked=encode_chunked)
0.525 File "/usr/lib/python3.10/http/client.py", line 1278, in endheaders
0.525 self._send_output(message_body, encode_chunked=encode_chunked)
0.525 File "/usr/lib/python3.10/http/client.py", line 1038, in _send_output
0.525 self.send(msg)
0.525 File "/usr/lib/python3.10/http/client.py", line 976, in send
0.526 self.connect()
0.526 File "/usr/lib/python3/dist-packages/docker/transport/unixconn.py", line 30, in connect
0.526 sock.connect(self.unix_socket)
0.526 FileNotFoundError: [Errno 2] No such file or directory
0.526
0.526 During handling of the above exception, another exception occurred:
0.526
0.526 Traceback (most recent call last):
0.526 File "/usr/lib/python3/dist-packages/requests/adapters.py", line 439, in send
0.526 resp = conn.urlopen(
0.526 File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 756, in urlopen
0.526 retries = retries.increment(
0.526 File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 532, in increment
0.526 raise six.reraise(type(error), error, _stacktrace)
0.526 File "/usr/lib/python3/dist-packages/six.py", line 718, in reraise
0.526 raise value.with_traceback(tb)
0.526 File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 700, in urlopen
0.526 httplib_response = self._make_request(
0.526 File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 395, in _make_request
0.527 conn.request(method, url, **httplib_request_kw)
0.527 File "/usr/lib/python3.10/http/client.py", line 1283, in request
0.527 self._send_request(method, url, body, headers, encode_chunked)
0.527 File "/usr/lib/python3.10/http/client.py", line 1329, in _send_request
0.527 self.endheaders(body, encode_chunked=encode_chunked)
0.527 File "/usr/lib/python3.10/http/client.py", line 1278, in endheaders
0.527 self._send_output(message_body, encode_chunked=encode_chunked)
0.527 File "/usr/lib/python3.10/http/client.py", line 1038, in _send_output
0.528 self.send(msg)
0.528 File "/usr/lib/python3.10/http/client.py", line 976, in send
0.528 self.connect()
0.528 File "/usr/lib/python3/dist-packages/docker/transport/unixconn.py", line 30, in connect
0.528 sock.connect(self.unix_socket)
0.528 urllib3.exceptions.ProtocolError: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))
0.528
0.528 During handling of the above exception, another exception occurred:
0.528
0.528 Traceback (most recent call last):
0.528 File "/usr/lib/python3/dist-packages/docker/api/client.py", line 214, in _retrieve_server_version
0.528 return self.version(api_version=False)["ApiVersion"]
0.528 File "/usr/lib/python3/dist-packages/docker/api/daemon.py", line 181, in version
0.528 return self._result(self._get(url), json=True)
0.528 File "/usr/lib/python3/dist-packages/docker/utils/decorators.py", line 46, in inner
0.528 return f(self, *args, **kwargs)
0.528 File "/usr/lib/python3/dist-packages/docker/api/client.py", line 237, in _get
0.528 return self.get(url, **self._set_request_timeout(kwargs))
0.528 File "/usr/lib/python3/dist-packages/requests/sessions.py", line 557, in get
0.528 return self.request('GET', url, **kwargs)
0.528 File "/usr/lib/python3/dist-packages/requests/sessions.py", line 544, in request
0.529 resp = self.send(prep, **send_kwargs)
0.529 File "/usr/lib/python3/dist-packages/requests/sessions.py", line 657, in send
0.529 r = adapter.send(request, **kwargs)
0.529 File "/usr/lib/python3/dist-packages/requests/adapters.py", line 498, in send
0.529 raise ConnectionError(err, request=request)
0.529 requests.exceptions.ConnectionError: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))
0.529
0.529 During handling of the above exception, another exception occurred:
0.529
0.529 Traceback (most recent call last):
0.529 File "/usr/bin/docker-compose", line 33, in <module>
0.529 sys.exit(load_entry_point('docker-compose==1.29.2', 'console_scripts', 'docker-compose')())
0.529 File "/usr/lib/python3/dist-packages/compose/cli/main.py", line 81, in main
0.529 command_func()
0.529 File "/usr/lib/python3/dist-packages/compose/cli/main.py", line 200, in perform_command
0.529 project = project_from_options('.', options)
0.529 File "/usr/lib/python3/dist-packages/compose/cli/command.py", line 60, in project_from_options
0.529 return get_project(
0.529 File "/usr/lib/python3/dist-packages/compose/cli/command.py", line 152, in get_project
0.529 client = get_client(
0.529 File "/usr/lib/python3/dist-packages/compose/cli/docker_client.py", line 41, in get_client
0.529 client = docker_client(
0.529 File "/usr/lib/python3/dist-packages/compose/cli/docker_client.py", line 170, in docker_client
0.530 client = APIClient(use_ssh_client=not use_paramiko_ssh, **kwargs)
0.530 File "/usr/lib/python3/dist-packages/docker/api/client.py", line 197, in __init__
0.530 self._version = self._retrieve_server_version()
0.530 File "/usr/lib/python3/dist-packages/docker/api/client.py", line 221, in _retrieve_server_version
0.530 raise DockerException(
0.530 docker.errors.DockerException: Error while fetching server API version: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))
------
Dockerfile:44
--------------------
42 |
43 | RUN sudo apt-get install docker-compose -y
44 | >>> RUN docker-compose -f /home/kasm-default-profile/Project-main/docker-compose.yml up -d --build
--------------------
ERROR: failed to solve: process "/bin/sh -c docker-compose -f /home/kasm-default-profile/Project-main/docker-compose.yml up -d --build" did not complete successfully: exit code: 1
The error is traced back to a python source code file, I need to use python3.8 for my project, which I have specified, but it sometimes mentions python3.10 which confuses me.
Any help would be greatly appreciated, thank you in advance.
CodeCrafter is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.