Exception or error:
i have laravel project and i want to create docker for it
and i want to automation it
i want to run this commends:
{
php artisan key:generate
php artisan migrate
php artisan queue:work –daemon
}
and its my docker-compose.yml file
version: '3'
services:
#PHP Service
app:
build:
context: .
dockerfile: Dockerfile
image: xxxx/lumen:Library
container_name: Library
restart: unless-stopped
tty: true
environment:
SERVICE_NAME: app
SERVICE_TAGS: dev
working_dir: /var/www
volumes:
- ./:/var/www
networks:
- app-network
#Nginx Service
webserver:
image: nginx:alpine
container_name: LibraryWebserver
restart: unless-stopped
tty: true
ports:
- "80:80"
- "443:443"
volumes:
- ./:/var/www
- ./nginx/conf.d/:/etc/nginx/conf.d/
networks:
- app-network
#MySQL Service
db:
image: mysql:5.7.22
container_name: Librarydb
restart: unless-stopped
tty: true
ports:
- "3306:3306"
environment:
MYSQL_DATABASE: library
MYSQL_ROOT_PASSWORD: Library!23
MYSQL_USER: root
MYSQL_PASSWORD: Library!23
SERVICE_TAGS: dev
SERVICE_NAME: mysql
networks:
- app-network
volumes:
- dbdata:/var/lib/mysql
#Docker Networks
networks:
app-network:
driver: bridge
#Volumes
volumes:
dbdata:
driver: local
i try to use command: php artisan migrate
and its do nothing
and also use
command: bash -c "php artisan migrate"
command: 'php artisan migrate'
How to solve:
You can use a command
like the below example. It will run the command once the container is up and running.
version: "3.0"
services:
app:
image: busybox
command: top
networks:
app_net:
link_local_ips:
- 57.123.22.11