WSL: How to make a file run automatically when the terminal is turned on

Asked 1 years ago, Updated 1 years ago, 108 views

Hi, how are you?

Every time I write wsl, I have to bind the environment variable related to docker. ~/.profile defines the related variables. Every time I turn on the terminal, I have to reload that file. When I tried to put it in the service and turn it around, systemctl didn't even run at all, so the following error occurs.

systemctlSystem has not been booted with systemd as init system (PID 1). Can't operate.

If you know how to put .profile on startup, please let me know.

wsl terminal

2022-09-22 12:00

2 Answers

On Linux, EXE cannot load files.

In addition, the problem of not being able to access the docker daemon can be caused by a number of reasons.

Perhaps this is the problem, but wsl does not automatically run the services. (It's very inconvenient and I recommend you to install and use Linux.))

Run the docker daemon with sudo service docker start.


2022-09-22 12:00

Below is ~/.profile or ~/.Variable added to bashrc.

#Docker
alias docker=docker.exe
alias docker-compose=docker-compose.exe
export PATH="$PATH:$HOME/.local/bin"
export DOCKER_HOST=0.0.0.0:2375

Below is an error message that comes out when you enter dockerps after modifying the bash source file when using Ubuntu.

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?


2022-09-22 12:00

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.