I'm new to docker and I'm trying to create a simple dot net core web api and mysql container composition.
I've done the following:
- Generated a starter project with the dot net sdk:
dotnet new webapi -o example-app - Created a Dockerfile in the project with the following content:
FROM microsoft/aspnetcore-build
WORKDIR /usr/src/app
COPY . .
EXPOSE 5000
ENTRYPOINT ["dotnet", "watch", "run"]
- Created a docker-compose.yml file with the following content:
version: "3"
services:
dot-net-rest-api:
container_name: docker-dot-net-rest-api
restart: always
build: .
environment:
- DBHOST=dot-net-mysql-db
- ASPNETCORE_ENVIRONMENT=Development
ports:
- '5000:80'
depends_on:
- dot-net-mysql-db
dot-net-mysql-db:
container_name: docker-dot-net-mysql-db
image: mysql:latest
restart: always
environment:
MYSQL_DATABASE: dot_net_rest_api_db
MYSQL_USER: user
MYSQL_PASSWORD: user
MYSQL_ROOT_PASSWORD: root
ports:
- 3306:3306
volumes:
- mysqldbdata:/var/lib/mysql
volumes:
mysqldbdata:
When i run docker-compose up I get the following output:
Creating network "example-app_default" with the default driver
Creating docker-dot-net-mysql-db ... done
Creating docker-dot-net-rest-api ... done
Attaching to docker-dot-net-mysql-db, docker-dot-net-rest-api
docker-dot-net-rest-api | /bin/sh: 1: [dotnet: not found
docker-dot-net-mysql-db | 2019-08-18T13:36:03.515008Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.
docker-dot-net-mysql-db | 2019-08-18T13:36:03.515151Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.17) starting as process 1
docker-dot-net-mysql-db | 2019-08-18T13:36:04.256200Z 0 [System] [MY-010229] [Server] Starting crash recovery...
docker-dot-net-mysql-db | 2019-08-18T13:36:04.267569Z 0 [System] [MY-010232] [Server] Crash recovery finished.
docker-dot-net-mysql-db | 2019-08-18T13:36:04.311086Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
docker-dot-net-mysql-db | 2019-08-18T13:36:04.315279Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
docker-dot-net-mysql-db | 2019-08-18T13:36:04.357081Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.17' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server - GPL.
docker-dot-net-mysql-db | 2019-08-18T13:36:04.481530Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: '/var/run/mysqld/mysqlx.sock' bind-address: '::' port: 33060
docker-dot-net-rest-api exited with code 127
docker-dot-net-rest-api exited with code 127
docker-dot-net-rest-api exited with code 127
docker-dot-net-rest-api exited with code 127
docker-dot-net-rest-api exited with code 127
docker-dot-net-rest-api exited with code 127
docker-dot-net-rest-api exited with code 127
...
What am i doing wrong?
https://hub.docker.com/r/microsoft/aspnetcore-build. UnderExample usagethere is a working example.ENTRYPOINT ["dotnet", "myapp.dll"]?