Weird error when deploying with pm2 and WSL2 - windows

I have a deploy.sh script which looks like this:
ssh -t <name> -<port> 'cd <foldername>; git pull; yarn build <appname>; pm2 restart <appname> --update-env'
It works perfectly when I'm using Windows Powershell but for some reason, it fails if I use my WSL terminal. It completes all stages of the script up until pm2 restart part, at this point error: unknown option --update-env appears, ssh connection closes and I have to manually connect to ssh server and restart pm2.
I'm not sure if there is a problem with my wsl or with pm2 but since '--update-env' is a pm2 option I guess it is pm2.
I'm using pm2 version 4.5.6
PSVersion 5.1.19041.1237
WSL2 Ubuntu-20.04.2 LTS

Related

Deploy jenkins with minikube in windows 10

I am trying to launch a jenkins on minikube on my windows computer.
For this, the first thing I have done has been to install minikube, virtualBox, kubectl and kubernetes-helm.
I have then run the following commands to pull up my minikube container and install jenkins.
minikube --memory 4096 --cpus 2 start --vm-driver=virtualbox
minikube status
helm repo add stable https://charts.helm.sh/stable/
helm upgrade --install myjenkins jenkins/jenkins
When I execute this last command, the following window appears:
My problem is that when I try to execute the command to know the password it gives me an error. I am working on a windows laptop. What would be the way to execute all the commands. With cmd, power shell, git bash?? I have tried to run it with all three and in none of them have I been able to execute the command to find out the password to enter jenkins that does seem to be up.

Why is the Docker service stopping?

I'm running Ubuntu as a subsystem on Windows 10.
I have just followed the steps to install Docker on Linux:
https://docs.docker.com/install/linux/docker-ce/ubuntu/
And are now at the step to test the hello-world app:
$ sudo docker run hello-world
Where I get this error:
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
I have narrowed it down to that it actually is the service that is not running - despite lots of other solutions online that more or less fixes this type of error.
When I check the status:
$ sudo service docker status
* Docker is not running
It says it's not running so I start it successfully:
$ sudo service docker start
* Starting Docker: docker [ OK ]
If I check the status immediately it says it's running. But when I check it again a few second later, it's not runnning:
$ sudo service docker status
* Docker is running
$ sudo service docker status
* Docker is not running
Why is the Docker service stopping and how can I keep it running?
What you got is as expected.
Microsoft does not support running the Docker daemon (also known as the service) within the WSL instance. You can refer to this discussion.
What you can do is just use docker client in WSL to connect to a remote docker engine which means docker daemon still on other PC.
But, if you use WSL2 which announced in May 6th, 2019, then, from microsoft's announcement, it could be(There is also a demo in this announcement which you can have a look):
Today we’re unveiling the newest architecture for the Windows Subsystem for Linux: WSL 2! Changes in this new architecture will allow for: dramatic file system performance increases, and full system call compatibility, meaning you can run more Linux apps in WSL 2 such as Docker.
You need either Docker on Windows:
https://medium.com/#sebagomez/installing-the-docker-client-on-ubuntus-windows-subsystem-for-linux-612b392a44c4

After installation, `docker info` is not working

I installed Dock via chocolatey install docker-toolbox. After installation, docker info is not working.
C:\Users\Chloe>docker info
error during connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.37/info: open
//./pipe/docker_engine: The system cannot find the file specified. In the default daemon configuration
on Windows, the docker client must be run elevated to connect. This error may also indicate that the
docker daemon is not running.
C:\Users\Chloe>docker --version
Docker version 18.03.0-ce, build 0520e24302
https://docs.docker.com/get-started/#test-docker-version
I did run it from an Administrator shell.
Windows 8.1.
Had to run Start > Programs > Docker > Docker Quickstart Terminal which ran a lot of commands. Then in my original Console2 shell, I ran refreshenv. Then docker info would work. (I already had VirtualBox installed (choco install virtualbox).)

Committing an interactive container in docker

I am trying to install the vim editor on bash in the centOS container in docker. However, as soon as I am exiting the container, I am losing my progress. Is there a way where I can commit the container after I am done with downloading the editor?
This is what I am doing:
user#personal-pc:~/Desktop$ sudo docker run -i -t centos /bin/bash
[root#9c0f428c4907 /]# yum install vim
After the installation is done, the editor works perfectly. However, when I end this running session, and run bash again, then the editor does not exist.
[root#d17ae0e8bf85 /]# vim abc.txt
bash: vim: command not found
How do I go about committing the previous container where the editor was installed?
when I end this running session
-> so now, you do docker commit 1234 mycontainer , if you start a new interactive session, you lose what you did before
commit the container 9c0f428c4907 with a new name.(After installing vim)
Eg: docker commit 9c0f428c4907 centos_viminstalled
Now run this cnetos_viminstalled image in a container
docker run -i -t cnetos_viminstalled /bin/bash
You will be able to see that vim is installed in this new image centos_viminstalled

What does the DOCKER_HOST variable do?

I'm new to Docker, using Boot2Docker on OSX. After booting it, this message is given:
To connect the Docker client to the Docker daemon, please set
export DOCKER_HOST=tcp://192.168.59.103:2375
Yet even without it, basic Docker commands (eg, docker run hello-world) work fine.
The install instructions aren't very informative:
Note: If you see a message in the terminal that looks something like this:
To connect the Docker client to the Docker daemon, please set:
export DOCKER_HOST=tcp://192.168.59.103:2375
you can safely set the evironment variable as instructed.
Knowing that it's "safe" doesn't say why it's useful.
What I'm not clear on:
What is the docker "client"?
What is the docker "daemon"?
What is the docker "host"? (The Boot2Docker VM itself?)
Ok, I think I got it.
The client is the docker command installed into OS X.
The host is the Boot2Docker VM.
The daemon is a background service running inside Boot2Docker.
This variable tells the client how to connect to the daemon.
When starting Boot2Docker, the terminal window that pops up already has DOCKER_HOST set, so that's why docker commands work. However, to run Docker commands in other terminal windows, you need to set this variable in those windows.
Failing to set it gives a message like this:
$ docker run hello-world
2014/08/11 11:41:42 Post http:///var/run/docker.sock/v1.13/containers/create:
dial unix /var/run/docker.sock: no such file or directory
One way to fix that would be to simply do this:
$ export DOCKER_HOST=tcp://192.168.59.103:2375
But, as pointed out by others, it's better to do this:
$ $(boot2docker shellinit)
$ docker run hello-world
Hello from Docker. [...]
To spell out this possibly non-intuitive Bash command, running boot2docker shellinit returns a set of Bash commands that set environment variables:
export DOCKER_HOST=tcp://192.168.59.103:2376
export DOCKER_CERT_PATH=/Users/ddavison/.boot2docker/certs/boot2docker-vm
export DOCKER_TLS_VERIFY=1
Hence running $(boot2docker shellinit) generates those commands, and then runs them.
Upon investigation, it's also worth noting that when you want to start using docker in a new terminal window, the correct command is:
$(boot2docker shellinit)
I had tested these commands:
>> docker info
Get http:///var/run/docker.sock/v1.15/info: dial unix /var/run/docker.sock: no such file or directory
>> boot2docker shellinit
Writing /Users/ddavison/.boot2docker/certs/boot2docker-vm/ca.pem
Writing /Users/ddavison/.boot2docker/certs/boot2docker-vm/cert.pem
Writing /Users/ddavison/.boot2docker/certs/boot2docker-vm/key.pem
export DOCKER_HOST=tcp://192.168.59.103:2376
export DOCKER_CERT_PATH=/Users/ddavison/.boot2docker/certs/boot2docker-vm
export DOCKER_TLS_VERIFY=1
>> docker info
Get http:///var/run/docker.sock/v1.15/info: dial unix /var/run/docker.sock: no such file or directory
Notice that docker info returned that same error. however.. when using $(boot2docker shellinit)...
>> $(boot2docker init)
Writing /Users/ddavison/.boot2docker/certs/boot2docker-vm/ca.pem
Writing /Users/ddavison/.boot2docker/certs/boot2docker-vm/cert.pem
Writing /Users/ddavison/.boot2docker/certs/boot2docker-vm/key.pem
>> docker info
Containers: 3
...
It points to the docker host! I followed these steps:
$ boot2docker start
Waiting for VM and Docker daemon to start...
..............................
Started.
To connect the Docker client to the Docker daemon, please set:
export DOCKER_HOST=tcp://192.168.59.103:2375
$ export DOCKER_HOST=tcp://192.168.59.103:2375
$ docker run ubuntu:14.04 /bin/echo 'Hello world'
Unable to find image 'ubuntu:14.04' locally
Pulling repository ubuntu
9cbaf023786c: Download complete
511136ea3c5a: Download complete
97fd97495e49: Download complete
2dcbbf65536c: Download complete
6a459d727ebb: Download complete
8f321fc43180: Download complete
03db2b23cf03: Download complete
Hello world
See:
http://docs.docker.com/userguide/dockerizing/

Resources