docker:Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Just solved a similar issue with this
The first thing you should do is to have Docker Desktop installed on your pc, of which you can get here https://docs.docker.com/desktop/windows/wsl/
You should also enable wsl2,
Just going through the documentation from the link above should be enough.
Make sure you go into Settings>Resources>WSL Integration and enable Ubuntu-20.04 or any other distro you are using.
Also make sure Settings>General>Use the WSL 2 based engine... box is checked
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? inside a Dockerfile
You can't (*) run Docker inside Docker containers or images. You can't (*) start background services inside a Dockerfile. As you say, commands like systemctl
and service
don't (*) work inside Docker anywhere. And in any case you can't use any host-system resources, including the host's Docker socket, from anywhere in a Dockerfile.
You need to redesign this Dockerfile so that it only installs the software and makes no attempt to start it. Ideally a container would start only a single server, and would run it in the foreground as its CMD; otherwise you might depend on things like supervisord to have multiple servers if you must. If your application heavily relies on being able to start things in Docker, you might find it much easier to install in a virtual machine.
(*) Technically there are ways to do all of these things, but they're all tricky and complicated and have implications (up to potentially giving your container unrestricted root access over the host, and your container startup actively reconfiguring some low-level host details).
Related Topics
Save Modifications in Place With Awk
How to Write Standard Error to a File While Using "Tee" With a Pipe
./Configure: /Bin/Sh^M: Bad Interpreter
How to Preserve Quotes in Printing a Bash Script'S Arguments
Tool to Trace Local Function Calls in Linux
The Difference Between Fork(), Vfork(), Exec() and Clone()
Why Should Eval Be Avoided in Bash, and What Should I Use Instead
What Does Set -E Mean in a Bash Script
Read Values into a Shell Variable from a Pipe
What Happens If There Is No Exit System Call in an Assembly Program
More Elegant "Ps Aux | Grep -V Grep"
How to Create Docker Overlay Network Between Multi Hosts
What's the Difference Between "Statically Linked" and "Not a Dynamic Executable" from Linux Ldd