docker run --name <container_name> -d -v $PWD:/var/www -p 80:80 hitalos/laravel
Where $PWD is the laravel installation folder.
With docker-compose
Create a docker-compose.yml file in the root folder of project using this as a template:
web:
image: hitalos/laravel:latestports:
- 80:80volumes:
- ./:/var/www# If you don't want to use default 'artisan serve' command, edit and uncomment the line below.# command: php -S 0.0.0.0:80 -t public public/index.php
Then run using this command:
docker-compose up
If you want to use a database, you can create your docker-compose.yml with two containers.
web:
image: hitalos/laravel:latestports:
- 80:80volumes:
- ./:/var/wwwlinks:
- dbenvironment:
DB_HOST: dbDB_DATABASE: dbnameDB_USERNAME: usernameDB_PASSWORD: p455w0rdDB_CONNECTION: [pgsql or mysql]db:
image: [postgres or mysql]environment:
# with mysqlMYSQL_DATABASE: dbnameMYSQL_USER: usernameMYSQL_PASSWORD: p455w0rd# with postgresPOSTGRES_DB: dbnamePOSTGRES_USER: usernamePOSTGRES_PASSWORD: p455w0rd
请发表评论