我在C#中用简单的应用程序连接postgreSQL。 我想用这个应用程序创建图像,并只与码头运行。用docker-compose运行docker图像
一切正常,当我使用:
$ docker build
$ docker run postgres
$ docker run my_app
此外,还有一切就OK了,当我使用的应用程序目录组成:
$ docker-compose build
$ docker-compose up
但有使用泊坞窗,撰写任何机会对于我之前建立的图像?
我想将此映像发布到我的回购站以及我团队中的其他人只需下载并运行此映像(app +数据库)即可。
当我连接到数据库中谱写构建和未来撰写运行程序my_app我有例外:
dbug: Npgsql.NpgsqlConnection[3]
Opening connection to database 'POSTGRES_USER' on server 'tcp://postgres:5432'.
Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.AggregateException: One or more errors occurred. (No such device or address) ---> System.Net.Internals.SocketExceptionFactory+ExtendedSocketException: No such device or address
我现在的码头工人,compose.yml文件:
version: '2'
services:
web:
container_name: 'postgrescoreapp'
image: 'postgrescoreapp'
build:
context: .
dockerfile: Dockerfile
volumes:
- .:/var/www/postgrescoreapp
ports:
- "5001:5001"
depends_on:
- "postgres"
networks:
- postgrescoreapp-network
postgres:
container_name: 'postgres'
image: postgres
environment:
POSTGRES_PASSWORD: password
networks:
- postgrescoreapp-network
networks:
postgrescoreapp-network:
driver: bridge
您应该可以创建一个使用您自己的图像的docker compose config,当然。使用'build'或'image'属性来构建图像或使用预定义的图像(您在回购站中托管):https://docs.docker.com/compose/compose-file/ – nwinkler
我已经使用它在我的docker-compose.yml文件中。 – ogrod87
那么你的问题是什么? – nwinkler