spurin / diveintoansible-lab

Dive Into Ansible Lab
850 stars 531 forks source link

Ubuntu containers exit with code 255 #70

Closed PDGIII closed 2 years ago

PDGIII commented 2 years ago

Getting the following error from docker-compose running on Ubuntu 21.10 as the host OS:

Attaching to centos2, docker, centos3, centos1, ubuntu-c, ubuntu1, ubuntu3, ubuntu2, portal portal | 2021/11/06 21:06:51 [emerg] 1#1: host not found in upstream "ubuntu1" in /etc/nginx/conf.d/default.conf:45 portal | nginx: [emerg] host not found in upstream "ubuntu1" in /etc/nginx/conf.d/default.conf:45 ubuntu2 exited with code 255 ubuntu-c exited with code 255 ubuntu1 exited with code 255 ubuntu3 exited with code 255 portal exited with code 1 docker exited with code 1

Looked through previous issues and past users seemed to experience this with WSL, not while running on Linux.

Any feedback would be greatly appreciated.

spurin commented 2 years ago

Hi @PDGIII

This version of Ubuntu is running cgroups v2 which, unfortunately causes problem with containers running systemd. If you install grubby, you can do -

sudo grubby --update-kernel=ALL --args="systemd.unified_cgroup_hierarchy=0"

And reboot. After doing so you should see this option on the output when you run -

cat /proc/cmdline

With this done, do a docker-compose rm, followed by a docker-compose up and you should be good!

Alternatively, there is also the option of running the lab for free as a Google cloudshell instance. You just need a Google credential for this -

https://github.com/spurin/diveintoansible-lab-gcp-cloudshell

Press the launch button, sign in with Google and follow the short tutorial on the right.

Please let me know how you get on 👍

PDGIII commented 2 years ago

@spurin - Thanks for the very quick response!

I'll check it out and report back.

PDGIII commented 2 years ago

@spurin - Ended up using Google cloudshell and it's working fine.

spurin commented 2 years ago

Thanks @PDGIII

Am currently working on containers that will hopefully work for cgroups v2 and v1 simultaneously. My intention if this is successful is to go through old issues relating to cgroups v2 and comment, therefore, you may hear from me on this in the future.

Hope you enjoy the course!

spurin commented 2 years ago

Hello again @PDGIII

I now have a branch on the diveintoansible-lab called release-candidate

Have been working on cgroupsv2 support and in my testing, I've used Ubuntu 21.10 as per your setup.

It's working well for me so if you want to try this on your system then please go ahead.

I've also made modifications to the .env file so you shouldn't need to change this either. It should just be a clone/download followed by a docker-compose up

If you give this a try, please let me know how you get on

Many thanks

James

PDGIII commented 2 years ago

@spurin - That worked. I'm now able to hit the web page from http://localhost:1000/ on my local machine and docker isn't spitting out any errors.

I appreciate the quick turnaround!

spurin commented 2 years ago

Fantastic! Thanks @PDGIII - appreciate your quick response on testing.

Have been working on this one for quite some time so am very happy its worked out well for you.

Enjoy the course from the convenience of your local system and subject to further platform testing, this should be merged soon 👍

PDGIII commented 2 years ago

Thanks!

I'm more than willing to help test in the future.

spurin commented 2 years ago

Hello again @PDGIII

After performing further testing on the images, I uncovered an annoying rabbit hole on some OS's where the images would fail upon restart. In your current setup, if for example you have it running, then you ctrl-c to stop and re-issue the docker-compose up command. The ubuntu containers may then fail with an exit code of Error 255.

This issue seems to relate to the host so in someway and was most likely kernel dependent on the source host.

After spending many hours on this I think I may have resolved it. If with your setup you can try the above (to see if you were affected), then do the following -

docker-compose rm
docker-compose pull
docker-compose up
<ctrl-c>
docker-compose up
<ctrl-c>
docker-compose up

Then that would be appreciated. As you can no doubt tell from the commands, am looking to verify that as well as working with cgroups v2, the container instances survive a docker stop/start.

p.s. all of this is still on the release-candidate branch

Thanks

James

PDGIII commented 2 years ago

Tried stopping/starting a few times and never ran into any issues.