Link to home
Start Free TrialLog in
Avatar of Jasmin shahrzad
Jasmin shahrzad

asked on

nginx docker

I have a nginx with many sites_enabled file how to configure if i move it to docker nginx?
Avatar of David Favor
David Favor
Flag of United States of America image

If you also have persistent data, like MariaDB/MySQL databases, likely LXD will be a better choice.

Docker is a better choice for ephemeral containers (those with no persistent data).

To move from a physical machine to either Docker or LXD is fairly straight forward.

Just requires a massive amount of time.

1) Create your containers.

2) Manually copy over all your sites into each container, one by one.

3) Alternative, if you're moving to LXD, is to migrate the entire machine into one LXD container using the lxd-p2c tool.

https://discuss.linuxcontainers.org/t/howto-use-lxd-p2c/3574 covers how to install + use lxd-p2c.

Normally the way I move machines with large numbers of sites (100s-1000s of sites) is to...

1) Use lxd-p2c to transfer entire machine into one container on a new machine.

2) Change IPs of all sites to use new container.

3) Retire old machine.

4) Then spin up new containers, moving either individual sites or collections of sites into the new container.

Once you get the hang of this, migrating machines with many sites to containers is a breeze.
Very easy though to add persistent volume to Docker if you so chose to.
Avatar of Jasmin shahrzad
Jasmin shahrzad

ASKER

i do not have data in my nginx server. it just server to remap site from other servers.
but i don't understand volume docker. should i create every site as a container or can i just create docker nginx with volume and move all
file from enabled-site to volume (which point to site enable in nginx docker) and it's running? or what?
is not working with volume. i can only see one site.
HELP
Help. i can't my site.
I have many site-available and enable in standalone server.
i pull nginx and create a volume and move all file in this volume. all port is define in mt compose file but i can't see the site.
browser say page not found. HELP
You asked, "but i don't understand volume docker."

Docker containers differ from physical machines + LXD containers, which both contain data + code.

Docker containers only contain code. Persistent data is arranged through Docker Volumes, which just means some part of your filesystem which is only accessed/changed by one (usually) Docker container.

So... usually this means...

Docker containers == pure code.

Docker volumes == pure data.
You said, "Help. i can't my site."

For best answers to questions, you'll setup your Docker container to enable NGINX debug logging, also container STDOUT/STDERR logging.

Then review your logs. Likely you'll instantly see source of whatever problem is occurring.

If not, then attach your NGINX + Docker logs in a comment.

Tip: Install sshd into your Docker container also, so you can ssh into your container + see exactly what's occurring. Be sure to also ensure bash or some sort of shell is installed, so ssh has some terminal/console code to run for interactivity.
@Shaun Vermaak
where to add in docker i can't do it under /usr/share/nginx/html
there should be another directory to share in docker. but which?
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.