How to run the Docker image using docker-compose? [duplicate]












0
















This question already has an answer here:




  • Deploying docker-compose containers

    1 answer




I have Flask application running under Docker Compose with 2 containers one for Flask and the other one for Nginx.



I am able to run the Flask successfully using docker-compose up --build -d command in my local machine.



What I want is, to save the images into .tar.gz file and move them to the production server and run them automatically. I have used below Bash script to save the Flask and Nginx into one image successfully.



#!/bin/bash

for img in $(docker-compose config | awk '{if ($1 == "image:") print $2;}'); do
images="$images $img"
done

docker save $images | gzip -c > flask_image.tar.gz


I then moved this image flask_image.tar.gz to my production server where Docker installed and used below command to load the image and run the containers.



docker load -i flask_image.ta.gz


This command loaded every layer and loaded the image into my production server. But containers are not up which is expected, since I used only load command.



My question is, is there any command that can load the image and up the containers automatically?



docker-compose.yml



version: '3'

services:

api:
container_name: flask
image: flask_img
restart: always
build: ./app
volumes:
- ~/docker_data/api:/app/uploads
ports:
- "8000:5000"
command: gunicorn -w 1 -b :5000 wsgi:app -t 900

proxy:
container_name: nginx
image: proxy_img
restart: always
build: ./nginx
volumes:
- ~/docker_data/nginx:/var/log/nginx/
ports:
- "85:80"
depends_on:
- api









share|improve this question















marked as duplicate by halfer, Matthieu Brucher, tripleee, Community Nov 23 '18 at 9:10


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.



















  • Images are already composed of tarballs but have extra data too. Instead of trying to tar an image, have you considered pushing your images to a docker registry? Docker hub is one option, google cloud and aws and azure also have registries to use if you're on those clouds. As a DevOps engineer I would consider it crazy to try to distribute docker images any other way.

    – Daniel Farrell
    Nov 21 '18 at 17:00











  • Can you please update some links on how to do it with docker registry. FYI, I have pushed my image to docker hub.

    – Reddi Mohan
    Nov 21 '18 at 17:05
















0
















This question already has an answer here:




  • Deploying docker-compose containers

    1 answer




I have Flask application running under Docker Compose with 2 containers one for Flask and the other one for Nginx.



I am able to run the Flask successfully using docker-compose up --build -d command in my local machine.



What I want is, to save the images into .tar.gz file and move them to the production server and run them automatically. I have used below Bash script to save the Flask and Nginx into one image successfully.



#!/bin/bash

for img in $(docker-compose config | awk '{if ($1 == "image:") print $2;}'); do
images="$images $img"
done

docker save $images | gzip -c > flask_image.tar.gz


I then moved this image flask_image.tar.gz to my production server where Docker installed and used below command to load the image and run the containers.



docker load -i flask_image.ta.gz


This command loaded every layer and loaded the image into my production server. But containers are not up which is expected, since I used only load command.



My question is, is there any command that can load the image and up the containers automatically?



docker-compose.yml



version: '3'

services:

api:
container_name: flask
image: flask_img
restart: always
build: ./app
volumes:
- ~/docker_data/api:/app/uploads
ports:
- "8000:5000"
command: gunicorn -w 1 -b :5000 wsgi:app -t 900

proxy:
container_name: nginx
image: proxy_img
restart: always
build: ./nginx
volumes:
- ~/docker_data/nginx:/var/log/nginx/
ports:
- "85:80"
depends_on:
- api









share|improve this question















marked as duplicate by halfer, Matthieu Brucher, tripleee, Community Nov 23 '18 at 9:10


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.



















  • Images are already composed of tarballs but have extra data too. Instead of trying to tar an image, have you considered pushing your images to a docker registry? Docker hub is one option, google cloud and aws and azure also have registries to use if you're on those clouds. As a DevOps engineer I would consider it crazy to try to distribute docker images any other way.

    – Daniel Farrell
    Nov 21 '18 at 17:00











  • Can you please update some links on how to do it with docker registry. FYI, I have pushed my image to docker hub.

    – Reddi Mohan
    Nov 21 '18 at 17:05














0












0








0









This question already has an answer here:




  • Deploying docker-compose containers

    1 answer




I have Flask application running under Docker Compose with 2 containers one for Flask and the other one for Nginx.



I am able to run the Flask successfully using docker-compose up --build -d command in my local machine.



What I want is, to save the images into .tar.gz file and move them to the production server and run them automatically. I have used below Bash script to save the Flask and Nginx into one image successfully.



#!/bin/bash

for img in $(docker-compose config | awk '{if ($1 == "image:") print $2;}'); do
images="$images $img"
done

docker save $images | gzip -c > flask_image.tar.gz


I then moved this image flask_image.tar.gz to my production server where Docker installed and used below command to load the image and run the containers.



docker load -i flask_image.ta.gz


This command loaded every layer and loaded the image into my production server. But containers are not up which is expected, since I used only load command.



My question is, is there any command that can load the image and up the containers automatically?



docker-compose.yml



version: '3'

services:

api:
container_name: flask
image: flask_img
restart: always
build: ./app
volumes:
- ~/docker_data/api:/app/uploads
ports:
- "8000:5000"
command: gunicorn -w 1 -b :5000 wsgi:app -t 900

proxy:
container_name: nginx
image: proxy_img
restart: always
build: ./nginx
volumes:
- ~/docker_data/nginx:/var/log/nginx/
ports:
- "85:80"
depends_on:
- api









share|improve this question

















This question already has an answer here:




  • Deploying docker-compose containers

    1 answer




I have Flask application running under Docker Compose with 2 containers one for Flask and the other one for Nginx.



I am able to run the Flask successfully using docker-compose up --build -d command in my local machine.



What I want is, to save the images into .tar.gz file and move them to the production server and run them automatically. I have used below Bash script to save the Flask and Nginx into one image successfully.



#!/bin/bash

for img in $(docker-compose config | awk '{if ($1 == "image:") print $2;}'); do
images="$images $img"
done

docker save $images | gzip -c > flask_image.tar.gz


I then moved this image flask_image.tar.gz to my production server where Docker installed and used below command to load the image and run the containers.



docker load -i flask_image.ta.gz


This command loaded every layer and loaded the image into my production server. But containers are not up which is expected, since I used only load command.



My question is, is there any command that can load the image and up the containers automatically?



docker-compose.yml



version: '3'

services:

api:
container_name: flask
image: flask_img
restart: always
build: ./app
volumes:
- ~/docker_data/api:/app/uploads
ports:
- "8000:5000"
command: gunicorn -w 1 -b :5000 wsgi:app -t 900

proxy:
container_name: nginx
image: proxy_img
restart: always
build: ./nginx
volumes:
- ~/docker_data/nginx:/var/log/nginx/
ports:
- "85:80"
depends_on:
- api




This question already has an answer here:




  • Deploying docker-compose containers

    1 answer








docker nginx flask docker-compose dockerfile






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 23 '18 at 8:51









halfer

14.7k759116




14.7k759116










asked Nov 21 '18 at 16:56









Reddi MohanReddi Mohan

538




538




marked as duplicate by halfer, Matthieu Brucher, tripleee, Community Nov 23 '18 at 9:10


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









marked as duplicate by halfer, Matthieu Brucher, tripleee, Community Nov 23 '18 at 9:10


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.















  • Images are already composed of tarballs but have extra data too. Instead of trying to tar an image, have you considered pushing your images to a docker registry? Docker hub is one option, google cloud and aws and azure also have registries to use if you're on those clouds. As a DevOps engineer I would consider it crazy to try to distribute docker images any other way.

    – Daniel Farrell
    Nov 21 '18 at 17:00











  • Can you please update some links on how to do it with docker registry. FYI, I have pushed my image to docker hub.

    – Reddi Mohan
    Nov 21 '18 at 17:05



















  • Images are already composed of tarballs but have extra data too. Instead of trying to tar an image, have you considered pushing your images to a docker registry? Docker hub is one option, google cloud and aws and azure also have registries to use if you're on those clouds. As a DevOps engineer I would consider it crazy to try to distribute docker images any other way.

    – Daniel Farrell
    Nov 21 '18 at 17:00











  • Can you please update some links on how to do it with docker registry. FYI, I have pushed my image to docker hub.

    – Reddi Mohan
    Nov 21 '18 at 17:05

















Images are already composed of tarballs but have extra data too. Instead of trying to tar an image, have you considered pushing your images to a docker registry? Docker hub is one option, google cloud and aws and azure also have registries to use if you're on those clouds. As a DevOps engineer I would consider it crazy to try to distribute docker images any other way.

– Daniel Farrell
Nov 21 '18 at 17:00





Images are already composed of tarballs but have extra data too. Instead of trying to tar an image, have you considered pushing your images to a docker registry? Docker hub is one option, google cloud and aws and azure also have registries to use if you're on those clouds. As a DevOps engineer I would consider it crazy to try to distribute docker images any other way.

– Daniel Farrell
Nov 21 '18 at 17:00













Can you please update some links on how to do it with docker registry. FYI, I have pushed my image to docker hub.

– Reddi Mohan
Nov 21 '18 at 17:05





Can you please update some links on how to do it with docker registry. FYI, I have pushed my image to docker hub.

– Reddi Mohan
Nov 21 '18 at 17:05












1 Answer
1






active

oldest

votes


















0














Since you mention you already are pushing the docker image to Docker Hub, that means the image has a dockerhub tag that you can use to pull it also.



Usually I use something like this to pull images that are on a registry:



docker run --rm -d --restart=always -p 80:8080 my-dockerhub-user/my-image-name:my-tag



which would run the container in daemon mode and restart if it were to fail. That's just an example; you'd want the ports to align with whatever flask is listening on (8080 in my example) and and the what your server should be listening on (80 in my example).



The server will automatically pull the image down and run it. You can use tags to promote new images, but in that case you'll have to kill the old container as well.






share|improve this answer


























  • since i am using flask and nginx, and mapping the ports. I am not sure If this idea works. I have updated my docker-compose.yml file

    – Reddi Mohan
    Nov 21 '18 at 17:16




















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Since you mention you already are pushing the docker image to Docker Hub, that means the image has a dockerhub tag that you can use to pull it also.



Usually I use something like this to pull images that are on a registry:



docker run --rm -d --restart=always -p 80:8080 my-dockerhub-user/my-image-name:my-tag



which would run the container in daemon mode and restart if it were to fail. That's just an example; you'd want the ports to align with whatever flask is listening on (8080 in my example) and and the what your server should be listening on (80 in my example).



The server will automatically pull the image down and run it. You can use tags to promote new images, but in that case you'll have to kill the old container as well.






share|improve this answer


























  • since i am using flask and nginx, and mapping the ports. I am not sure If this idea works. I have updated my docker-compose.yml file

    – Reddi Mohan
    Nov 21 '18 at 17:16


















0














Since you mention you already are pushing the docker image to Docker Hub, that means the image has a dockerhub tag that you can use to pull it also.



Usually I use something like this to pull images that are on a registry:



docker run --rm -d --restart=always -p 80:8080 my-dockerhub-user/my-image-name:my-tag



which would run the container in daemon mode and restart if it were to fail. That's just an example; you'd want the ports to align with whatever flask is listening on (8080 in my example) and and the what your server should be listening on (80 in my example).



The server will automatically pull the image down and run it. You can use tags to promote new images, but in that case you'll have to kill the old container as well.






share|improve this answer


























  • since i am using flask and nginx, and mapping the ports. I am not sure If this idea works. I have updated my docker-compose.yml file

    – Reddi Mohan
    Nov 21 '18 at 17:16
















0












0








0







Since you mention you already are pushing the docker image to Docker Hub, that means the image has a dockerhub tag that you can use to pull it also.



Usually I use something like this to pull images that are on a registry:



docker run --rm -d --restart=always -p 80:8080 my-dockerhub-user/my-image-name:my-tag



which would run the container in daemon mode and restart if it were to fail. That's just an example; you'd want the ports to align with whatever flask is listening on (8080 in my example) and and the what your server should be listening on (80 in my example).



The server will automatically pull the image down and run it. You can use tags to promote new images, but in that case you'll have to kill the old container as well.






share|improve this answer















Since you mention you already are pushing the docker image to Docker Hub, that means the image has a dockerhub tag that you can use to pull it also.



Usually I use something like this to pull images that are on a registry:



docker run --rm -d --restart=always -p 80:8080 my-dockerhub-user/my-image-name:my-tag



which would run the container in daemon mode and restart if it were to fail. That's just an example; you'd want the ports to align with whatever flask is listening on (8080 in my example) and and the what your server should be listening on (80 in my example).



The server will automatically pull the image down and run it. You can use tags to promote new images, but in that case you'll have to kill the old container as well.







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 23 '18 at 8:53









halfer

14.7k759116




14.7k759116










answered Nov 21 '18 at 17:14









Daniel FarrellDaniel Farrell

6,18711417




6,18711417













  • since i am using flask and nginx, and mapping the ports. I am not sure If this idea works. I have updated my docker-compose.yml file

    – Reddi Mohan
    Nov 21 '18 at 17:16





















  • since i am using flask and nginx, and mapping the ports. I am not sure If this idea works. I have updated my docker-compose.yml file

    – Reddi Mohan
    Nov 21 '18 at 17:16



















since i am using flask and nginx, and mapping the ports. I am not sure If this idea works. I have updated my docker-compose.yml file

– Reddi Mohan
Nov 21 '18 at 17:16







since i am using flask and nginx, and mapping the ports. I am not sure If this idea works. I have updated my docker-compose.yml file

– Reddi Mohan
Nov 21 '18 at 17:16







Popular posts from this blog

鏡平學校

ꓛꓣだゔៀៅຸ໢ທຮ໕໒ ,ໂ'໥໓າ໼ឨឲ៵៭ៈゎゔit''䖳𥁄卿' ☨₤₨こゎもょの;ꜹꟚꞖꞵꟅꞛေၦေɯ,ɨɡ𛃵𛁹ޝ޳ޠ޾,ޤޒޯ޾𫝒𫠁သ𛅤チョ'サノބޘދ𛁐ᶿᶇᶀᶋᶠ㨑㽹⻮ꧬ꧹؍۩وَؠ㇕㇃㇪ ㇦㇋㇋ṜẰᵡᴠ 軌ᵕ搜۳ٰޗޮ޷ސޯ𫖾𫅀ल, ꙭ꙰ꚅꙁꚊꞻꝔ꟠Ꝭㄤﺟޱސꧨꧼ꧴ꧯꧽ꧲ꧯ'⽹⽭⾁⿞⼳⽋២៩ញណើꩯꩤ꩸ꩮᶻᶺᶧᶂ𫳲𫪭𬸄𫵰𬖩𬫣𬊉ၲ𛅬㕦䬺𫝌𫝼,,𫟖𫞽ហៅ஫㆔ాఆఅꙒꚞꙍ,Ꙟ꙱エ ,ポテ,フࢰࢯ𫟠𫞶 𫝤𫟠ﺕﹱﻜﻣ𪵕𪭸𪻆𪾩𫔷ġ,ŧآꞪ꟥,ꞔꝻ♚☹⛵𛀌ꬷꭞȄƁƪƬșƦǙǗdžƝǯǧⱦⱰꓕꓢႋ神 ဴ၀க௭எ௫ឫោ ' េㇷㇴㇼ神ㇸㇲㇽㇴㇼㇻㇸ'ㇸㇿㇸㇹㇰㆣꓚꓤ₡₧ ㄨㄟ㄂ㄖㄎ໗ツڒذ₶।ऩछएोञयूटक़कयँृी,冬'𛅢𛅥ㇱㇵㇶ𥄥𦒽𠣧𠊓𧢖𥞘𩔋цѰㄠſtʯʭɿʆʗʍʩɷɛ,əʏダヵㄐㄘR{gỚṖḺờṠṫảḙḭᴮᵏᴘᵀᵷᵕᴜᴏᵾq﮲ﲿﴽﭙ軌ﰬﶚﶧ﫲Ҝжюїкӈㇴffצּ﬘﭅﬈軌'ffistfflſtffतभफɳɰʊɲʎ𛁱𛁖𛁮𛀉 𛂯𛀞నఋŀŲ 𫟲𫠖𫞺ຆຆ ໹້໕໗ๆทԊꧢꧠ꧰ꓱ⿝⼑ŎḬẃẖỐẅ ,ờỰỈỗﮊDžȩꭏꭎꬻ꭮ꬿꭖꭥꭅ㇭神 ⾈ꓵꓑ⺄㄄ㄪㄙㄅㄇstA۵䞽ॶ𫞑𫝄㇉㇇゜軌𩜛𩳠Jﻺ‚Üမ႕ႌႊၐၸဓၞၞၡ៸wyvtᶎᶪᶹစဎ꣡꣰꣢꣤ٗ؋لㇳㇾㇻㇱ㆐㆔,,㆟Ⱶヤマފ޼ޝަݿݞݠݷݐ',ݘ,ݪݙݵ𬝉𬜁𫝨𫞘くせぉて¼óû×ó£…𛅑הㄙくԗԀ5606神45,神796'𪤻𫞧ꓐ㄁ㄘɥɺꓵꓲ3''7034׉ⱦⱠˆ“𫝋ȍ,ꩲ軌꩷ꩶꩧꩫఞ۔فڱێظペサ神ナᴦᵑ47 9238їﻂ䐊䔉㠸﬎ffiﬣ,לּᴷᴦᵛᵽ,ᴨᵤ ᵸᵥᴗᵈꚏꚉꚟ⻆rtǟƴ𬎎

Why https connections are so slow when debugging (stepping over) in Java?