blog/create-sql-server-database-from-a-script-in-docker-compose/ #1625
Replies: 10 comments
-
so how can i load the asp.net core app ? |
Beta Was this translation helpful? Give feedback.
-
@ango21 In the docker-compose.yml example above, the services:
other.service:
image: my/aspnet-core-app/image/name
build:
context: .
dockerfile: MyAspNetCore.App/Dockerfile
environment:
- ConnectionString=Data Source=CONTAINER_NAME_OF_db;Initial Catalog=DB_NAME;User Id=sa;Password=Your_password123;Pooling=False;Max Pool Size=200;MultipleActiveResultSets=True
depends_on:
- db
db:
image: my/db/image/name
build:
context: .
dockerfile: data/Dockerfile
# ports:
# - "1444:1433"
volumes:
- mssqldata:/var/opt/mssql
volumes:
mssqldata: |
Beta Was this translation helpful? Give feedback.
-
Thanks a lot. I am new and confused about using two dockerfiles. Also, should I need multiple entrypoints ? |
Beta Was this translation helpful? Give feedback.
-
I would like to understand the choice of entrypoint.sh for asp.net dockerfile. the link you mentioned uses the entrypoint to start the sql server and waiting for it. Do you think I can get away with it. |
Beta Was this translation helpful? Give feedback.
-
@ango21 By using docker-compose, we are starting two or more containers (from their own Dockerfile/image), in this example a SQL server container and another container that uses the container instance of SQL server. This article explains the SQL server part to run in the docker with DB initialized (i.e with the database created, tables defined, even data can be seeded). The Regarding asp.net core Dockerfile, it will be something like this which you can easily generate by using visual studio. |
Beta Was this translation helpful? Give feedback.
-
This really helped me clear my confusion of the pathway. I have another question, the associative libraries of the web application should be in the same web container or should i need to put them in another container ? And what is the intuitive way of understanding the container ports ? is it the container name associated with the container or do I need to specifically remember the mapped port. |
Beta Was this translation helpful? Give feedback.
-
@ango21 Regarding referenced libraries, see the image below. Which is showing docker image of one of my side projects piggyvault. As you can see, the referenced projects are copied to the same container in order to build and run the application. Regarding the container ports, have a look at this. |
Beta Was this translation helpful? Give feedback.
-
the connection string is in the environment variable is a bit confusing to me. I am loading two SQL script through the entrypoint.sh, but the docker container is somehow not responding and getting exited. also the connection string initial catalog is describing what ? I am using two databases which needs loading. how to change the connection script then ? do i need two of them ? |
Beta Was this translation helpful? Give feedback.
-
One more thing, how to make sure that the ports are binded ? |
Beta Was this translation helpful? Give feedback.
-
SOrry, the complete question would be how to forward the port of aps.net to the sql database docker port |
Beta Was this translation helpful? Give feedback.
-
Create SQL Server Database From a Script in Docker-Compose | Abhith Rajan
Run a SQL Server container with database initialized from a script using docker-compose.
https://www.abhith.net/blog/create-sql-server-database-from-a-script-in-docker-compose/
Beta Was this translation helpful? Give feedback.
All reactions