![]() ![]() ![]() starting with a new db) append the -v flag at the end of the previous command. To delete all the persistent data related to your deploy (i.e. To bring down your deploy just use docker-compose down. Note that this port has to be free (no other system services are using it), otherwise the entire deployment will fail.įinal note: since docker-compose will try to avoid to build your images every time you bring up the service, to force it to build a new one you have to append -build to the docker-compose up command. Note that no ports are exposed here: only your service will be able to access the database from db:3306 (you don't need to refer by IP, but you can reach other services using the service name).įor debug purposes, you can still open your db ports adding this line under image: ports: To launch and deploy your application, now you need to type in a terminal: You can see existing volumes typing 'docker volume ls' ĭepends_on: # set a dependency between your service and the database: this means that your application will not run if the db service is not running, but it doesn't assure you that the dabase will be ready to accept incoming connection (so your application could crash untill the db initializes itself)ĭb_data: # this tells docker-compose to save your data in a generic docker volume. # this tells docker-compose to not pull from docker hub, but to build from the Dockerfile it will find in. Restart: always # if the db crash somehow, restart itĮnvironment: # env variables, you usually set this to override existing onesīuild. Volumes: # this section allows you to configure persistence within multiple restarts Image: mysql:5.7 # the image and tag docker will pull from docker hub Services: # list of services composing your applicationĭb: # the service hosting your MySQL instance So, for example, a suitable configuration for your application (note: I'm assuming you're using MySQL 5.7 since you haven't specified one) could be: version: '3.3' This file usually contains all the configuration your application needs to run. Otherwise, as you suggested, there is the possibility to set up a docker-compose file. If you've launched MySQL exposing the ports you should be able to reach it connecting from localhost, with the port 3306. RUN dotnet publish "ToDoService.csproj" -c Release -o /app RUN dotnet build "ToDoService.csproj" -c Release -o /app ![]() RUN dotnet restore "ToDoService/ToDoService.csproj" But I am able to connect to the MySql db using workbench.Īlso I am not sure but can these two setups be combined into some file I think they're called docker-compose files maybe?ĭockerfile FROM microsoft/aspnetcore:2.0 AS baseįROM microsoft/aspnetcore-build:2.0 AS buildĬOPY If I write the GetDBAddress function what goes in there? I cannot simply return localhost because it's another docker container? As of right now I am trying to use localhost and I get connection refused. Services.AddDbContext(options => options.UseMySQL(connection)) Var connection = $"Server= Database=myDataBase Uid=root Pwd=root " Net Core Program: public void ConfigureServices(IServiceCollection services) Net Core program to is the IP address of the MySql container if the IP can change? I created the MySql container using this statement:ĭocker run -name mysql_container -d -p 3306:3306īelow is the dockerfile that Visual Studio generated for me. I have already started the MySql container and setup the root account to work. Net core website are in their separate containers. So some background, both the MySql and the. Net Core website to connect to my MySql container. Inside you will see the database connection credentials.I know this is such a noob problem but I am having trouble understanding how to get my. Better option was to check MySQL init process done. Any connection attempt before it will result in failure. Final print is after Temporary server stopped. Problem was that in container MySQL prints mysqld: ready for connections twice in logs. You can confirm this: $ docker exec -user=magento2 -it magento2devbox_web_12345678 /bin/bash I did not try disabling this defaultauthenticationplugin. The default username:password is root:root. I assume this process generalizes to the MySQL container. In the guide you linked, it looks like there are instructions to set up a static port so that connecting with PHPStorm is less burdensome. This means that you can use a MySQL client like Sequel Pro or MySQL Workbench to connect: Host: 127.0.0.1īut you can always check with docker ps. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |