Access all subnet hosts from docker container

I am new to docker container , have been able to successfully create a docker container image that install all dependancies and expose port 80 of web server i.e. apache , and localhost port 80 is mapped to port 80 of container. Now when I check http://localhost I am able to see the response.

Now next step is I have VPC configured on AWS and two subnets configured under VPC. My application will be talking to different backend servers like database/search engine/cache layer under both subnets.

I need to detailed document , how networking works in docker. I can create a docker network like following

docker network create -d bridge --subnet --gateway dockernet

this command create a docker network with subnet but In my case I have two different subnets so how to configure docker network in my situation and will --gateway will always have the private IP of underlying host?

Need to subnet your network but don’t know how to do it? We will help you and explain that how can you do it properly.

When a Docker image is executed, the Docker Engine creates a temporary file system on which all the components and data generated by the container are stored. It relies on the copy-on-write capabilities of the Union File System. In practice, the implementation of this copy-on-write mechanism means that when the same image is instantiated multiple times on the same host, the Docker Engine does not create a complete copy of the image but stores as the changes made by each image being executed. This mechanism not only saves space, but also saves time, especially when starting the container - which allows, in some cases, to instantiate a container in a few tenths of a second. You can learn more about it to follow