Ringo
Ringo

Reputation: 5473

Issue editing nginx.conf using Docker and NGINX

I'm having trouble figuring out how to edit nginx.conf inside NGINX open source Docker container.

I'm trying to follow the directions here:

https://docs.nginx.com/nginx/admin-guide/installing-nginx/installing-nginx-docker/#maintaining-content-and-configuration-files-in-the-container

I've gotten through all 4 steps succcessfully. I have SSH access using the helper mynginx4_files container.

This part confuses me, though:

  • the /bin/bash argument means that the bash shell runs in the helper container, presenting a shell prompt that you can use to modify files as needed

This sounds good! I do have the bash prompt now, but unfortunately, I don't see any way I can modify nginx.conf. There's no text editor that I can see. I don't see vi or emacs or anything else. (I searched through all 4 'bin' directories, and whereis and find didn't turn up anything for vi.) I tried to install vi using apt-get but was unsuccessful. I even tried ubuntu instead of debian, but even with ubuntu there is no text editor. I thought vi is standard on all Linux distributions. I don't know what's up, but I feel like I'm missing something big here. Any help greatly appreciated.

Upvotes: 0

Views: 2090

Answers (1)

atline
atline

Reputation: 31574

You don't need to edit nginx.conf in the container, you can just create a new nginx.conf on the host, modify it, and use -v to map it to the container.

Something like:

docker run --name my-custom-nginx-container -v /host/path/nginx.conf:/etc/nginx/nginx.conf:ro -d nginx

Maybe also have a look at nginx on docker hub

Upvotes: 3

Related Questions