Hi Guys, I would like to share a volume,my Apache load balance is doing redirect to specific container. I have cache on my code, we can’t go with cluster or pm2 module.
echo "Create N/W"
docker network create --subnet=123.45.6.0/16 selnet
echo "Start Db Conatiner"
docker run -t -d --net selnet --ip 123.45.6.2 --name xDB --restart always -p 27017:27017 -v dev_mongodb_volume:/data/db:Z docker.xyz.com/xyz-apid/digital_x_dev/mongo:version1.0
echo "Start app Conatiner"
docker run -t -d -e PORT=8000 --net selnet --ip 123.45.6.3 --link=xDB:mongodb --restart always -v dev_images_volume:/apps/data/images/:Z -v dev_files_volume:/apps/data/files/:Z -v dev_dx_logs_volume:/root/.pm2/logs/:Z -p 8000:8000 --name AppContainer -h digitalocean.aps-dev.aws-nonprod.xyzcloud.com docker.xyz.com/xyz-apid/digital_x_dev/backend:version1.4.0 tail -f /dev/null
docker run -t -d -e PORT=8001 --net selnet --ip 123.45.6.5 --link=xDB:mongodb --restart always -p 8001:8001 --name AppContainer1 --volumes-from AppContainer:AppContainer1 -h digitalocean.aps-dev.aws-nonprod.xyzcloud.com docker.xyz.com/xyz-apid/digital_x_dev/backend:version1.4.0 tail -f /dev/null
docker run -t -d -e PORT=8002 --net selnet --ip 123.45.6.6 --link=xDB:mongodb --restart always -p 8002:8002 --name AppContainer2 --volumes-from AppContainer:AppContainer2 -h digitalocean.aps-dev.aws-nonprod.xyzcloud.com docker.xyz.com/xyz-apid/digital_x_dev/backend:version1.4.0 tail -f /dev/null
docker run -t -d -e PORT=8003 --net selnet --ip 123.45.6.7 --link=xDB:mongodb --restart always -p 8003:8003 --name AppContainer3 --volumes-from AppContainer:AppContainer3 -h digitalocean.aps-dev.aws-nonprod.xyzcloud.com docker.xyz.com/xyz-apid/digital_x_dev/backend:version1.4.0 tail -f /dev/null
docker run -t -d -e PORT=8004 --net selnet --ip 123.45.6.8 --link=xDB:mongodb --restart always -p 8004:8004 --name AppContainer4 --volumes-from AppContainer:AppContainer4 -h digitalocean.aps-dev.aws-nonprod.xyzcloud.com docker.xyz.com/xyz-apid/digital_x_dev/backend:version1.4.0 tail -f /dev/null
docker run -t -d -e PORT=8005 --net selnet --ip 123.45.6.9 --link=xDB:mongodb --restart always -p 8005:8005 --name AppContainer5 --volumes-from AppContainer:AppContainer5 -h digitalocean.aps-dev.aws-nonprod.xyzcloud.com docker.xyz.com/xyz-apid/digital_x_dev/backend:version1.4.0 tail -f /dev/null
docker run -t -d -e PORT=8006 --net selnet --ip 123.45.6.10 --link=xDB:mongodb --restart always -p 8006:8006 --name AppContainer6 --volumes-from AppContainer:AppContainer6 -h digitalocean.aps-dev.aws-nonprod.xyzcloud.com docker.xyz.com/xyz-apid/digital_x_dev/backend:version1.4.0 tail -f /dev/null
docker run -t -d -e PORT=8007 --net selnet --ip 123.45.6.11 --link=xDB:mongodb --restart always -p 8007:8007 --name AppContainer7 --volumes-from AppContainer:AppContainer7 -h digitalocean.aps-dev.aws-nonprod.xyzcloud.com docker.xyz.com/xyz-apid/digital_x_dev/backend:version1.4.0 tail -f /dev/null
echo "Start apache Conatiner"
docker run -t -d --net selnet --ip 123.45.6.4 --restart always -p 80:80 -p 443:443 --name AppApachedigitalocean -h digitalocean.aps-dev.aws-nonprod.xyzcloud.com:8000 -v dev_apache_logs_volume:/etc/httpd/logs:Z docker.xyz.com/xyz-apid/digital_x_dev/apache_ssl:version1.4
cd dist
sudo su
docker cp AppContainer:/apps/x/backend/dist/ .
docker cp dist/. AppApachedigitalocean:/var/www/html/.
echo "start digitalocean-dev"
docker container exec -d AppContainer mv /apps/x/backend/dist /apps/x/backend/dist1
Working Code, but can’t share files or folders with other containers:
echo "Create N/W"
docker network create --subnet=123.45.6.0/16 selnet
echo "Start Db Conatiner"
docker run -t -d --net selnet --ip 123.45.6.2 --name xDB --restart always -p 27017:27017 -v dev_mongodb_volume:/data/db:Z docker.xyz.com/xyz-apid/digital_x_dev/mongo:version1.0
echo "Start app Conatiner"
docker run -t -d -e PORT=8000 --net selnet --ip 123.45.6.3 --link=xDB:mongodb --restart always -v dev_images_volume:/apps/data/images/:Z -v dev_files_volume:/apps/data/files/:Z -v dev_dx_logs_volume:/root/.pm2/logs/:Z -p 8000:8000 --name AppContainer -h digitalocean.aps-dev.aws-nonprod.xyzcloud.com docker.xyz.com/xyz-apid/digital_x_dev/backend:version1.4.0 tail -f /dev/null
docker run -t -d -e PORT=8001 --net selnet --ip 123.45.6.5 --link=xDB:mongodb --restart always -p 8001:8001 --name AppContainer1 -h digitalocean.aps-dev.aws-nonprod.xyzcloud.com docker.xyz.com/xyz-apid/digital_x_dev/backend:version1.4.0 tail -f /dev/null
docker run -t -d -e PORT=8002 --net selnet --ip 123.45.6.6 --link=xDB:mongodb --restart always -p 8002:8002 --name AppContainer2 -h digitalocean.aps-dev.aws-nonprod.xyzcloud.com docker.xyz.com/xyz-apid/digital_x_dev/backend:version1.4.0 tail -f /dev/null
docker run -t -d -e PORT=8003 --net selnet --ip 123.45.6.7 --link=xDB:mongodb --restart always -p 8003:8003 --name AppContainer3 -h digitalocean.aps-dev.aws-nonprod.xyzcloud.com docker.xyz.com/xyz-apid/digital_x_dev/backend:version1.4.0 tail -f /dev/null
docker run -t -d -e PORT=8004 --net selnet --ip 123.45.6.8 --link=xDB:mongodb --restart always -p 8004:8004 --name AppContainer4 -h digitalocean.aps-dev.aws-nonprod.xyzcloud.com docker.xyz.com/xyz-apid/digital_x_dev/backend:version1.4.0 tail -f /dev/null
echo "Start apache Conatiner"
docker run -t -d --net selnet --ip 123.45.6.4 --restart always -p 80:80 -p 443:443 --name AppApachedigitalocean -h digitalocean.aps-dev.aws-nonprod.xyzcloud.com:8000 -v dev_apache_logs_volume:/etc/httpd/logs:Z docker.xyz.com/xyz-apid/digital_x_dev/apache_ssl:version1.4
cd dist
sudo su
docker cp AppContainer:/apps/x/backend/dist/ .
docker cp dist/. AppApachedigitalocean:/var/www/html/.
echo "start digitalocean-dev"
docker container exec -d AppContainer mv /apps/x/backend/dist /apps/x/backend/dist1
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Hi there @kalapanabudhe,
I believe that when you do
--volumes-from
it needs to be followed only by the name of the container that you want to use the volumes from. Have you tried chaning the following:To:
I ran the following test and it worked as expected:
test1
and with a volume calleddev_images_volume
:Then I used the
--volumes-from
flag to create a second container calledtest2
:After checking the containers both were sharing the same volume.
Hope that this helps!
Regards,
Bobby