-
Notifications
You must be signed in to change notification settings - Fork 602
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WSL2 docker for windows / docker-compose up issues #4
Comments
Hello Oscar,
The CONFIG entry, should point to diveintoansible-lab/config
The ANSIBLE_HOME entry should point to diveintoansible-lab/ansible_home
I think the CONFIG one is the important one here which is causing an issue for you more so than the ANSIBLE_HOME but if you can humour me and set it as per the examples I give that would be great (tweak it later when it’s working).
The environment has been tested as is across many different environments (before release) and since launch, there’s been many pulls of the images so you shouldn’t be needing, to create those directories manually 👍
Let’s see how you get on with the config update and then go from there.
…> On 18 Dec 2020, at 18:05, oscarmparedes ***@***.***> wrote:
Hi!
this is my .env file:
# sshd ports
UBUNTUC_PORT_SSHD=2221
UBUNTU1_PORT_SSHD=2222
UBUNTU2_PORT_SSHD=2223
UBUNTU3_PORT_SSHD=2224
CENTOS1_PORT_SSHD=2225
CENTOS2_PORT_SSHD=2226
CENTOS3_PORT_SSHD=2227
# ttyd (web terminal) ports
UBUNTUC_PORT_TTYD=7681
UBUNTU1_PORT_TTYD=7682
UBUNTU2_PORT_TTYD=7683
UBUNTU3_PORT_TTYD=7684
CENTOS1_PORT_TTYD=7685
CENTOS2_PORT_TTYD=7686
CENTOS3_PORT_TTYD=7687
# Shared config volume
CONFIG=/home/{{user}}/diveintoansible-lab
# Shared home directories
ANSIBLE_HOME=/home/{{user}}/.ansible`
This is the output of docker-compose up command:
`docker-compose up
Creating network "diveinto.io" with the default driver
Creating ubuntu-c ... done
Creating centos3 ... done
Creating ubuntu1 ... done
Creating ubuntu2 ... done
Creating centos2 ... done
Creating docker ... done
Creating centos1 ... done
Creating ubuntu3 ... done
Creating portal ... done
Attaching to centos3, ubuntu-c, centos2, ubuntu1, ubuntu2, docker, ubuntu3, centos1, portal
ubuntu-c exited with code 255
ubuntu1 exited with code 255
ubuntu2 exited with code 255
ubuntu3 exited with code 255
portal | 2020/12/18 17:51:29 [emerg] 1#1: host not found in upstream "ubuntu1" in /etc/nginx/conf.d/default.conf:46
portal | nginx: [emerg] host not found in upstream "ubuntu1" in /etc/nginx/conf.d/default.conf:46
portal exited with code 1
Given that the autocreate dirs feature for bind volumes is deprecated, I created dirs manually just in case, with these commands:
docker/compose#2781
`mkdir -p ~/.ansible/ubuntu[1,2,3]
mkdir -p ~/.ansible/centos[1,2,3]
mkdir -p ~/.ansible/ubuntu-c
mkdir -p ~/.ansible/shared
ls -la ~/.ansible/
total 40
drwxr-xr-x 4 root root 4096 Dec 18 18:16 centos1
drwxr-xr-x 4 root root 4096 Dec 18 18:16 centos2
drwxr-xr-x 4 root root 4096 Dec 18 18:16 centos3
drwxr-xr-x 2 root root 4096 Dec 18 18:16 shared
drwxr-xr-x 4 root root 4096 Dec 18 18:16 ubuntu-c
drwxr-xr-x 4 root root 4096 Dec 18 18:16 ubuntu1
drwxr-xr-x 4 root root 4096 Dec 18 18:16 ubuntu2
drwxr-xr-x 4 root root 4096 Dec 18 18:16 ubuntu3
`
Client: Docker Engine - Community
Cloud integration: 1.0.2
Version: 19.03.13
API version: 1.40
Go version: go1.13.15
Git commit: 4484c46d9d
Built: Wed Sep 16 17:02:36 2020
OS/Arch: linux/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 19.03.13
API version: 1.40 (minimum version 1.12)
Go version: go1.13.15
Git commit: 4484c46d9d
Built: Wed Sep 16 17:07:04 2020
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: v1.3.7
GitCommit: 8fba4e9a7d01810a393d5d25a3621dc101981175
runc:
Version: 1.0.0-rc10
GitCommit: dc9208a3303feef5b3839f4323d9beb36df0a9dd
docker-init:
Version: 0.18.0
GitCommit: fec3683
Still I couldn't make it work. Any suggestions?, centos images run but ubuntu ones don't. I also checked the layers but I really couldn't find what is happening.
https://hub.docker.com/layers/spurin/diveintoansible/ubuntu/images/sha256-3ee94e9bffdb108bc1c34b78558a415a0690779082d8edb15b59b952f0691b76?context=explore
Thanks in advance, and hope this helps others.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
To add to this, I expect the lab to be run as a mortal user, I notice in your case that the mkdir ended up with root owned directories being created.
… On 18 Dec 2020, at 18:05, oscarmparedes ***@***.***> wrote:
Hi!
this is my .env file:
# sshd ports
UBUNTUC_PORT_SSHD=2221
UBUNTU1_PORT_SSHD=2222
UBUNTU2_PORT_SSHD=2223
UBUNTU3_PORT_SSHD=2224
CENTOS1_PORT_SSHD=2225
CENTOS2_PORT_SSHD=2226
CENTOS3_PORT_SSHD=2227
# ttyd (web terminal) ports
UBUNTUC_PORT_TTYD=7681
UBUNTU1_PORT_TTYD=7682
UBUNTU2_PORT_TTYD=7683
UBUNTU3_PORT_TTYD=7684
CENTOS1_PORT_TTYD=7685
CENTOS2_PORT_TTYD=7686
CENTOS3_PORT_TTYD=7687
# Shared config volume
CONFIG=/home/{{user}}/diveintoansible-lab
# Shared home directories
ANSIBLE_HOME=/home/{{user}}/.ansible`
This is the output of docker-compose up command:
`docker-compose up
Creating network "diveinto.io" with the default driver
Creating ubuntu-c ... done
Creating centos3 ... done
Creating ubuntu1 ... done
Creating ubuntu2 ... done
Creating centos2 ... done
Creating docker ... done
Creating centos1 ... done
Creating ubuntu3 ... done
Creating portal ... done
Attaching to centos3, ubuntu-c, centos2, ubuntu1, ubuntu2, docker, ubuntu3, centos1, portal
ubuntu-c exited with code 255
ubuntu1 exited with code 255
ubuntu2 exited with code 255
ubuntu3 exited with code 255
portal | 2020/12/18 17:51:29 [emerg] 1#1: host not found in upstream "ubuntu1" in /etc/nginx/conf.d/default.conf:46
portal | nginx: [emerg] host not found in upstream "ubuntu1" in /etc/nginx/conf.d/default.conf:46
portal exited with code 1
Given that the autocreate dirs feature for bind volumes is deprecated, I created dirs manually just in case, with these commands:
docker/compose#2781
`mkdir -p ~/.ansible/ubuntu[1,2,3]
mkdir -p ~/.ansible/centos[1,2,3]
mkdir -p ~/.ansible/ubuntu-c
mkdir -p ~/.ansible/shared
ls -la ~/.ansible/
total 40
drwxr-xr-x 4 root root 4096 Dec 18 18:16 centos1
drwxr-xr-x 4 root root 4096 Dec 18 18:16 centos2
drwxr-xr-x 4 root root 4096 Dec 18 18:16 centos3
drwxr-xr-x 2 root root 4096 Dec 18 18:16 shared
drwxr-xr-x 4 root root 4096 Dec 18 18:16 ubuntu-c
drwxr-xr-x 4 root root 4096 Dec 18 18:16 ubuntu1
drwxr-xr-x 4 root root 4096 Dec 18 18:16 ubuntu2
drwxr-xr-x 4 root root 4096 Dec 18 18:16 ubuntu3
`
Client: Docker Engine - Community
Cloud integration: 1.0.2
Version: 19.03.13
API version: 1.40
Go version: go1.13.15
Git commit: 4484c46d9d
Built: Wed Sep 16 17:02:36 2020
OS/Arch: linux/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 19.03.13
API version: 1.40 (minimum version 1.12)
Go version: go1.13.15
Git commit: 4484c46d9d
Built: Wed Sep 16 17:07:04 2020
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: v1.3.7
GitCommit: 8fba4e9a7d01810a393d5d25a3621dc101981175
runc:
Version: 1.0.0-rc10
GitCommit: dc9208a3303feef5b3839f4323d9beb36df0a9dd
docker-init:
Version: 0.18.0
GitCommit: fec3683
Still I couldn't make it work. Any suggestions?, centos images run but ubuntu ones don't. I also checked the layers but I really couldn't find what is happening.
https://hub.docker.com/layers/spurin/diveintoansible/ubuntu/images/sha256-3ee94e9bffdb108bc1c34b78558a415a0690779082d8edb15b59b952f0691b76?context=explore
Thanks in advance, and hope this helps others.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Hi Spurin!, Thanks for your quick reply. Ok, for some reason I copied over the .env file without the config part. Now I didn't create any dirs manually, you are totally right it creates the dirs automatically, but not sure why docker-compose creates the dirs as root. .env
and still same error, but this is the verbose output:
|
Hi Oscar, I think you can ignore the permissions on the directory, Docker is running as root and docker-compose is passing off to Docker, hence the permissions. We'll get to the bottom of this, even if we need to break it down into stages. Just seeing how we can break this up for further testing, will update shortly. |
Thank you very much. I could make this work perfect in a vagrant box, so I am concerned it maybe has to do with something in docker vs using WSL2 engine. |
It's a good opportunity to find out whats wrong so we'll try and troubleshoot this for now. Okay, some stages - Let's see if you can run the ansible container as it is, quite simply, you should get a login and then just be able to exit -
|
This works.
|
Next, let's test the directory mounts -
|
|
Okay so thats interesting. By the way, are you running this as a standalone Linux Ubuntu system or is it running in another virtualisation layer? Let's see the permissions -
|
Ok this is docker desktop for windows with WSL2 engine enabled. I am using a WLS2 ubuntu 20.04 image.
It was docker-compose that created this dir btw. It does work perfectly fine in an Ubuntu 20.04 Vagrant box. |
Understood. You could also directly run the lab from Windows and I don't think you'll have these problems. Let's try this -
|
Sure, I am actually testing this for a friend that started your course. I am using my work laptop (windows only), and I need WSL2 to have linux for work. I think the WSL2 is doing something strange with permissions.
|
Try this - docker run -v /home/oscar/diveintoansible-lab/config:/config -v /home/oscar/diveintoansible-lab/ansible_home:/ansible_home --rm -p 12345:7681 --privileged -it spurin/diveintoansible:ansible ls /config /ansible_home |
|
Okay great, earlier on it was missing the :/ansible_lab bit, can you try this for me next please -
You should, if all goes well be able to login to http://localhost:12345 Can you try this out and share the output, if it's not working. Note, to stop this, you'll need a new terminal and will need to do -
|
|
Okay so this is brings us closer to the problem. For reference, to mimic a real operating system in the containers, the container image is running systemd.
Throughout the course this allows us to use things like services like we would in a full Linux OS.
I believe, because of the Vagrant virtualisation layer that’s in the middle, you’re lacking the core needed to run this.
We can dig a little bit further (might take me a bit of time to experiment with this) but just to warn, this might turn out to be a ‘wont fix’.
The lab is meant to be run either directly in Windows, Mac OS X or Linux, not with another virtualisation layer in the middle, therefore, I’ve no idea how far this can be taken at present 👍
Will experiment and see.
… On 18 Dec 2020, at 20:57, oscarmparedes ***@***.***> wrote:
docker run --name diveintodebug -v /home/oscar/diveintoansible-lab/config:/config -v /home/oscar/diveintoansible-lab/ansible_home/ubuntu-c/ansible:/home/ansible -v /sys/fs/cgroup:/sys/fs/cgroup:ro --rm -p 12345:7681 --privileged -it spurin/diveintoansible:ansible
Failed to mount cgroup at /sys/fs/cgroup/systemd: No such file or directory
[!!!!!!] Failed to mount API filesystems.
Exiting PID 1...
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
This is great and I hope it is useful for someone else I think I found a fix. So for the record:
Looks like it works by using this. So if anyone is using Docker for windows with WSL2 engine, maybe this is the fix for your lab to work in this kind of environment. microsoft/WSL#4189 |
Fantastic,
Thanks for the update and really glad to hear you got it working. What one was you using previously?
… On 18 Dec 2020, at 21:23, oscarmparedes ***@***.***> wrote:
This is great and I hope it is useful for someone else I think I found a fix. So for the record:
This tests where made in a WSL2 linux box (Ubuntu 20.04) under windows.
I am using docker for windows with WSL2 support enabled. https://docs.docker.com/docker-for-windows/wsl/
This repo worked for me perfectly on a Vagrant box (virtualbox vm). https://app.vagrantup.com/bento/boxes/ubuntu-20.04
Looks like it works by using this. So if anyone is using Docker for windows with WSL2 engine, maybe this is the fix for your lab to work in this kind of environment. microsoft/WSL#4189
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
More precisely, if using WSL2, and Docker for windows with WSL2 engine support enabled, try running like this:
As per answering your questions, the tests we were doing before were done from WSL2 Ubuntu 20.04 box, not Vagrant. Vagrant worked fine from the beginning is just this setup. It's just a workaround, not a proper fix, I will keep investigating. Very cool lab by the way. Congrats! |
Excellent,
Appreciate you sharing this extra detail. Thanks for your time to work through this to completion.
I hope you and your friend enjoy the course 🚀
… On 18 Dec 2020, at 21:29, oscarmparedes ***@***.***> wrote:
More precisely:
sudo mkdir -p /sys/fs/cgroup/systemd
:~/diveintoansible-lab$ sudo mount -t cgroup -o none,name=systemd cgroup /sys/fs/cgroup/systemd
:~/diveintoansible-lab$ docker-compose up
Creating network "diveinto.io" with the default driver
Creating ubuntu1 ... done
Creating ubuntu2 ... done
Creating ubuntu-c ... done
Creating centos2 ... done
Creating centos1 ... done
Creating centos3 ... done
Creating ubuntu3 ... done
Creating docker ... done
Creating portal ... done
Attaching to ubuntu2, ubuntu1, ubuntu-c, centos2, centos1, ubuntu3, docker, centos3, portal
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Welcome! Happy to help! |
Hi!
this is my .env file:
This is the output of docker-compose up command:
Given that the autocreate dirs feature for bind volumes is deprecated, I created dirs manually just in case, with these commands:
docker/compose#2781
Still I couldn't make it work. Any suggestions?, centos images run but ubuntu ones don't. I also checked the layers but I really couldn't find what is happening.
https://hub.docker.com/layers/spurin/diveintoansible/ubuntu/images/sha256-3ee94e9bffdb108bc1c34b78558a415a0690779082d8edb15b59b952f0691b76?context=explore
Thanks in advance, and hope this helps others.
The text was updated successfully, but these errors were encountered: