Laradock notes

  • The official documentation
  • Chinese document

Installation steps

  1. First clone the Laradock project code to the local:
git clone https://github.com/Laradock/laradock.git
  1. Go to the laradock directory and rename env-example to.env:
cp env-example .env

In order to avoid the network timeout problem during the mirroring process, change the Linux software source to the domestic mirror in.env:

CHANGE_SOURCE
# If you need to change the sources (i.e. to China), set CHANGE_SOURCE to true
CHANGE_SOURCE=true
# Set CHANGE_SOURCE and UBUNTU_SOURCE option if you want to change the Ubuntu system sources.list file.
UBUNTU_SOURCE=aliyun
  1. Build the image & start the container:
docker-compose up -d nginx mysql redis beanstalkd

Nginx is built on top of php-fpm, and php-fpm is built on a workspace, so starting nginx will start the workspace and php-fpm first.

If the specified port is already occupied, running the above command will report an error. Close the corresponding service and rerun the above command.

If an error is reported during the mirroring process of the above command in Windows system:

/tmp/sources.sh: not found

Refer the issue to solve: https://github.com/laradock/l… .

  1. Open the.env file for the Laravel project and add the following configuration:
DB_HOST=mysql # Enter the name of the container (laradock_redis_1) or the IP address of the container (172.28.0.5)

Other commands

  • Build the image & start the container
docker-compose up -d nginx mysql redis beanstalkd
  • Rebuild the container
'docker-compose', 'compose', 'compose', 'compose'
  • After adding a project, restart Docker’s nginx
docker-compose up -d nginx
  • List the container
If you just want to see the container for the current project, you can also use the following command docker-compose ps
  • Restart all containers in the current project (you can easily do this if you don’t want to open each container one by one).
docker-compose restart
  • Closed container
Docker-compose compose stop {container-name} docker-compose stop {container-name} docker-compose stop {container-name} docker-compose stop {container-name}
  • Into the container
Docker-compose exec {container-name} bash docker-compose exec {container-name} bash Create, compose, compose, compose, compose, compose, compose, compose, compose, compose, compose, compose, compose, compose, compose PHPUnit, Gulp, ...) Docker-compose exec workspace bash
  • Delete all existing containers
docker-compose down
  • Nginx log files are stored in logs/ NGINX directory but you need to view other containers (Mysql, php-fpm…). You can run the following command
docker-compose logs {container-name}

docker-compose logs -f {container-name}

Install the swoole in the laradock

To install Laradock locally, for example, set the following two lines to true from.env in the Laradock directory:

WORKSPACE_INSTALL_SWOOLE=true
PHP_FPM_INSTALL_SWOOLE=true

Then run docker-compose build php-fpm workspace and rebuild the docker container. After that, restart the two containers, enter the workspace container and run php-m to see if Swoole was installed successfully. If Swoole is included in the extension list, the installation is successful.

Other matters needing attention

inlaravelFramework, if the configuration does not work, please pay attention to clean uplaravelThe cache

php artisan config:clear

Check to see if port 5200 is open

Install the netstat command to look at the ports


apt-get update


apt-get install net-tools


netstat -ntlp

netstat -ant | grep 5200

Port mapping on mode

  1. Enter thelaradock/docker-compose.yml

Added in Ports under Workspace

ports: - "${WORKSPACE_SSH_PORT}:22" - "${WORKSPACE_VUE_CLI_SERVE_HOST_PORT}:8080" - "${WORKSPACE_VUE_CLI_UI_HOST_PORT}:8000" - "${WORKSPACE_PORT}:5200" /** If you add 5200/5200 to the line, you don't need to set the variable **/ in.env
  1. Enter the.envWORKSPACEThe next last row is incremented
WORKSPACE_AST_VERSION = 1.0.3 WORKSPACE_VUE_CLI_SERVE_HOST_PORT WORKSPACE_VUE_CLI_UI_HOST_PORT = 8080 = 8001 WORKSPACE_INSTALL_GIT_PROMPT=false WORKSPACE_PORT=5200 /** The new line in this action is actually setting the variable **/ in Step 1

Some bloggers say also need to be at the end of the laradock/workspace/Dockerfile file, add a line that open port: EXPOSE 5200, here, I didn’t do this step, is also a success, if you don’t succeed, try again after you add to it

  1. Force the workspace container to be recreated
docker-compose up -d --force-recreate workspace
  1. restartdocker-compose
docker-compose restart 

docker ps
  1. Test whether the port was opened successfully
Telnet 127.0.0.1 5200 # or check the port list for the container docker port {container-name} # Here's docker port laradock_workspace_1

Original link address