Recently, I am preparing the docker image which is necessary for one course project. The OS version is Linux CentOS. The docker image should contain all necessary libraries that the project needs.
Step1. Install Python3.7
The following links tell users how to install python3 on linux
This was caused by the python version. /usr/bin/yum is written in python2 snytax, whereas I have upgrade my python to python3 and setup the soft link “python => python3”. Fortunately, the following link solves my problem. And during the process of reinstalling docker, I use this trick to solve several similar errors.
It still didn’t solve my problem after I completely uninstall and install docker for several times. I got the same error when I start the docker. So I decide to investigate on this more carefully, first thing is to check the exact error.
[root@izwz9h66f1dwk5qi56kfs0z ~]# systemctl start docker A dependency job for docker.service failed. See 'journalctl -xe'for details. [root@izwz9h66f1dwk5qi56kfs0z ~]# journalctl -xe Feb 28 13:34:35 izwz9h66f1dwk5qi56kfs0z systemd[1]: containerd.service: main process exited, code=exited, status=203/EXEC Feb 28 13:34:35 izwz9h66f1dwk5qi56kfs0z systemd[1]: Failed to start containerd container runtime. -- Subject: Unit containerd.service has failed -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- Unit containerd.service has failed. -- -- The result is failed. Feb 28 13:34:35 izwz9h66f1dwk5qi56kfs0z systemd[1]: Dependency failed for Docker Application Container Engine. -- Subject: Unit docker.service has failed -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- Unit docker.service has failed. -- -- The result is dependency. Feb 28 13:34:35 izwz9h66f1dwk5qi56kfs0z systemd[1]: Job docker.service/start failed with result 'dependency'. Feb 28 13:34:35 izwz9h66f1dwk5qi56kfs0z systemd[1]: Unit containerd.service entered failed state. Feb 28 13:34:35 izwz9h66f1dwk5qi56kfs0z systemd[1]: containerd.service failed. Feb 28 13:34:35 izwz9h66f1dwk5qi56kfs0z polkitd[398]: Unregistered Authentication Agent for unix-process:8386:350732 (system bus name :1.505, object Feb 28 13:34:40 izwz9h66f1dwk5qi56kfs0z systemd[1]: containerd.service holdoff time over, scheduling restart. Feb 28 13:34:40 izwz9h66f1dwk5qi56kfs0z systemd[1]: Starting containerd container runtime... -- Subject: Unit containerd.service has begun start-up -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- Unit containerd.service has begun starting up. Feb 28 13:34:40 izwz9h66f1dwk5qi56kfs0z systemd[8413]: Failed at step EXEC spawning /usr/bin/containerd: No such file or directory -- Subject: Process /usr/bin/containerd could not be executed -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- The process /usr/bin/containerd could not be executed and failed. -- -- The error number returned by this process is 2. Feb 28 13:34:40 izwz9h66f1dwk5qi56kfs0z systemd[1]: containerd.service: main process exited, code=exited, status=203/EXEC Feb 28 13:34:40 izwz9h66f1dwk5qi56kfs0z systemd[1]: Failed to start containerd container runtime. -- Subject: Unit containerd.service has failed -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- Unit containerd.service has failed. -- -- The result is failed. Feb 28 13:34:40 izwz9h66f1dwk5qi56kfs0z systemd[1]: Unit containerd.service entered failed state. Feb 28 13:34:40 izwz9h66f1dwk5qi56kfs0z systemd[1]: containerd.service failed.
The main error is the following:
containerd.service: main process exited, code=exited, status=203/EXEC
Failed at step EXEC spawning /usr/bin/containerd: No such file or directory
My understanding is that when the system want to boot docker, it failed to start containerd container at runtime. The above error is the reason. Then the system try to “Starting containerd container runtime…” again, this time the following errors occurred. According to what I have found, it seems that this is not a bug. This problem is due to the incorrect environment or path settings of the user.
Anyway, after trying for 5 hours, I give up fixing this bug. This is quite annoying to work all day on this problem with no progress. I reset all the server and start everything from scratch. If time allowed, in the future I will try to solve this problem. But now I have tons of things to do…
Therefore, the first step should be Step0. Install Docker and then continue step1,2
Now, after the stupid “all start from scratch”. I successfully start my docker. And I am also aware of the lack of knowledge of linux. Previously I add one new user named zxy in centos. However, I need to switch back and forth between root and zxy, which brings me lots of trouble since the authority of different usr differs. Every time when I want to modify some system related files, I have to use sudo and input my password. So this time, I will only focus on root user since there will be nobody except me using this server.
# add the ./recommender into container folder /recommender # later we can go into the container to see this ADD ./recommender /recommender ADD ./requirements.txt /tmp/requirements.txt
# install dependencies RUN pip install -r /tmp/requirements.txt
# set the working directory to be /recommender WORKDIR /recommender
# expose the port EXPOSE4001
# when starting the container # use python3 to execute the py shell script of the specified path CMD ["python3", "/recommender/main.py"] CMDecho"---end---" CMD /bin/bash
This may stuck in pip install, so we can simply ignore the dependency installation. We can first create a simple image, create a container using that image, enter it and install (mirror accelerated), then build a new image based on this container.
Up till now, the python environment and docker image construction is done.
Some other problems
VScode is too slow when connecting the remote server. Try to delete the ./.vscode file and reconnect.
After resetting the server, local ssh connection will get “remote key has changed” error Delete the corresponding ssh key from ./ssh/knownhost (notice, not to delete all of them)