I have my simple app in C# that connect with postgreSQL.
I would like to create image with this app and just run with docker.
Everything is ok when I use:
$ docker build $ docker run postgres $ docker run my_app
Additionally, there is everything ok, when I use compose from application directory:
$ docker-compose build $ docker-compose up
But is there any chance for use docker-compose for image that I built previous?
I would like to publish this image to my repo and somebody else from my team just download and run this image (app + database).
When I do compose-build and next compose run my_app I have exception during connecting to database:
dbug: Npgsql.NpgsqlConnection 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
My current docker-compose.yml file:
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