I’m very new to the entire Docker issue, and am having a lot of problems that I can’t easily explain. I’m running Docker Community engine v19.03.5 on a 4GB RaspberryPi4 and trying hard to come to terms with the concept. So, I’ve downloaded and can successfully run the nginx web-server image in what might be called a ‘base mode’ using the command ‘sudo docker run --name mynginx1 -d -p 8080:80 nginx
’. I should add that I’m quite happy that this is in ‘sudo’ mode, and that it is NOT a critical system at all - anything can be discarded, including, if necessary the entire OS (which is Raspbian Buster kernel 4.19.75-v7l+ #1270). I can look at the IP address of the Pi in a browser, using port 8080 and ‘see’ the standard Nginx index file. All good. So then I want to manage the content and configuration files. If I stop and remove the running Nginx, and then create another instance with:
‘sudo docker run --name mynginx2 -v /var/www:/user/share/nginx/html:ro -d -p 8080:80 nginx
’
after, of course, creating a directory on the host at /var/www which contains a simple html file, looking at the web server as before, I see the new file. Exactly as I’ve been led to expect.
So now, I stop and remove this instance and try again, except this time - as many websites are encouraging me to do - I use:
’sudo docker run --name mynginx3 -v /var/nginx/conf:/etc/nginx:ro -d -p 8080:80 nginx'
with a view that I can modify the configuration file, I always get:
> curl: (7) Failed to connect to localhost port 8080: Connection refused
and this is driving me crazy!!! Why? Why does the first work exactly as expected but the second - which by all accounts should work equally as well - give me this refusal to connect? Oh, and of course, I have created the directory /var/nginx/conf. What am I doing wrong - or am I seriously misunderstanding something? (Yes, and I can see there might be other ways to do this, but why doesn’t this - supposedly simple - approach work?). Any comments from those with far more experience gratefully received!! Mike