docker-compose

difference between localhost and postgres for host in docker

孤街醉人 提交于 2020-01-23 21:20:10
问题 I am developing a django app and trying to run it inside docker. I have an issue that I could not understand so far. while running the app with docker-compose , it seems that the web app cannot connect to the database when i use these configurations: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'my_db', 'USER': 'my_user', 'PASSWORD': '', 'HOST': 'localhost', 'PORT': '5432', } but once I change the host to postgres , it works. like this DATABASES = {

difference between localhost and postgres for host in docker

流过昼夜 提交于 2020-01-23 21:20:06
问题 I am developing a django app and trying to run it inside docker. I have an issue that I could not understand so far. while running the app with docker-compose , it seems that the web app cannot connect to the database when i use these configurations: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'my_db', 'USER': 'my_user', 'PASSWORD': '', 'HOST': 'localhost', 'PORT': '5432', } but once I change the host to postgres , it works. like this DATABASES = {

Cannot connect to mongodb instance from docker: Connection refused

半世苍凉 提交于 2020-01-23 12:46:09
问题 I am using docker-compose to create a multi-container environment where I have one mongodb instance and two python applications. The problem is, the first application is able to establish a connection to mongodb whereas the second application fails with the following error: File "/usr/local/lib/python2.7/site-packages/pymongo/mongo_client.py", line 377, in __init__ notification_1 | raise ConnectionFailure(str(e)) notification_1 | pymongo.errors.ConnectionFailure: [Errno -2] Name or service

Docker linked containers, Docker Networks, Compose Networks - how should we now 'link' containers

隐身守侯 提交于 2020-01-23 06:42:06
问题 I have an existing app that comprises of 4 docker containers running on the same host. They have been linked together using the link command. However, after some upgrades of docker, the link behaviour has been deprecated, and changed it seems. We are having issues where containers are loosing the link to each other now. So, docker says to use the new Network feature over link ed containers. But I can't see how this works. If 2 containers are in the same network, are the same ENV vars

Locked package.json files in Docker container using docker-compose

。_饼干妹妹 提交于 2020-01-23 06:23:26
问题 I'm using Docker for Mac and Docker Compose for development of a Node.js application and I'm experiencing an error with the package.json file being locked. The specific error after running npm install --save <package> within a running container is: npm WARN saveError EBUSY: resource busy or locked, rename '/Example/package.json.1647356251' -> '/Example/package.json' The simplified package structure is: ▾ docker/ Dockerfile docker-compose.yaml package.json The Dockerfile contains: FROM node:9

What benefits does Docker Compose have over Docker Swarm and Docker Stack?

南楼画角 提交于 2020-01-23 04:56:47
问题 From what I read it seems that Docker-Compose is a tool to create multiple containers on a single host while Docker Swarm is a tool that can do the exact same thing but with more control and on multiple hosts with the help of Docker Stack. I went through the tutorial and also came across this thread: docker-compose.yml vs docker-stack.yml what difference? And I'm coming to the conclusion that there's no reason to ever use Docker-Compose when you can use Docker Swarm with Docker Stack. They

Can you use nginx reverse proxy to docker containers without exposing any ports?

余生颓废 提交于 2020-01-23 03:25:27
问题 I'd like to know if it's possible to use nginx with docker compose as an api gateway / reverse proxy / ssl termination point without exposing any ports on the containers behind it. I.e. I want to use only the intranet created by docker compose when the containers are linked to communicate past nginx. Ideally the only publicly accessible port will be port 443 (ssl) on nginx. Is this doable? Or do I have to expose ports on my containers? 回答1: Yes is doable. Just define your application in one

Speed up docker-compose shutdown

≡放荡痞女 提交于 2020-01-23 02:15:32
问题 When I set up my application to run via docker-compose up , it takes several seconds to stop on ctrl+c. However, if I run docker kill ... , the container stops very quickly. Is there anything I can do to speed up container shutdown when killed via ctrl+c within docker-compose up ? In particular, what does it actually mean when docker-compose says it is "gracefully stopping "? Is docker-compose trying some shutdown protocol and then killing my container only after a timeout? 回答1: what does it

Docker高级管理(实例演示!!!)

萝らか妹 提交于 2020-01-22 23:11:22
Docker网络通信 Docker单机网络拓扑图: 端口映射: 端口映射机制将容器内的服务提供给外部网络访问 可随机或指定映射端口范围 docker run -d -P httpd:centos docker run -d -p 49888:80 httpd:centos 容器互联 在源容器和接收容器间建立一条网络通信隧道 使用docker run命令–link选项实现容器间互联通信 实现容器互联 docker run -d -P --name web1 httpd:centos docker run -d -P --name web2 --link web1:web1 httpd:centos docker exec -it web2 /bin/bash ping web1 Docker Compose容器编排 Docker Compose的前身是Fig,它是一个定义及运行多个Docker容器的工具 使用Docker Compose不再需要使用shell脚本来启动容器 Docker Compose非常适合组合使用多个容器进行开发的场景 Docker Compose环境安装 [root@localhost ~]# curl -Lhttps://github.com/docker/compose/releases/download/1.21.1 /docker-compose-

使用微信公众号开发模拟面试功能

依然范特西╮ 提交于 2020-01-22 22:43:09
最近在整理我在大厂面试以及平时工作中遇到的问题,记录在 shfshanyue/Daily-Question 中,但觉得对于时时回顾,常常复习仍然做的不够。 于是在微信公众号中开发了随机生成模拟面试的功能,由于觉得比较简单且有趣,于是分享了出来 需求 先来谈一谈需求点: 在公众号中回复面试,随机生成 N 道大厂面试题 每道面试题指向一个超链接,可以查看答案 需求很简单,如图下所示。你也可以去我的公众号 全栈成长之路 查看实现效果 内容 在大部分行业中,内容是至为重要的,有内容才会有好的服务,而技术只是整合内容的一种手段。 在本次功能开发中也是如此: 一个面试题库才是至关重要 。 为此,我在 github 上新建了一个仓库,使用 Issue 来记录我在大厂面试中所遇到的面试题及答案 每天一道面试题,有关前端,后端,devops以及软技能,促进职业成长,敲开大厂之门。 到此一步,我拥有了自己的内容,并且拥有了开箱即用的后台管理系统: github issues 数据 此时我们已经拥有了一个特殊的后台管理系统,但很遗憾,由于该管理系统的特殊性,我们并不是数据映射管理系统,而需要根据 Github Issues 来生成结构化的数据,好在我们可以使用 Github API。 Github API 现在已经全部变成了 GraphQL 接口,看来大家又需要学习一门新的技术了。关于 Github