Docker Php Composer



Estimated reading time: 14 minutes

FROM php:7.2-fpm # Copy composer.lock and composer.json COPY composer.lock composer.json /var/www/ # Set working directory WORKDIR /var/www # Install dependencies RUN apt-get update && apt-get install -y build-essential libpng-dev libjpeg62-turbo-dev libfreetype6-dev locales zip jpegoptim optipng pngquant gifsicle vim unzip. Docker Desktop offers support for users subscribed to a Pro or a Team plan. If you are experiencing any issues with Docker Desktop, follow the instructions in this section to send a support request to Docker Support. Before you get started, we recommend that you sign into your Docker Desktop application and your Docker Hub account. ├──.docker │ └── php │ ├── Dockerfile │ └── vhost.conf ├── app ├── artisan ├── bootstrap ├── config ├── database ├── public ├── readme.md ├── resources ├── routes ├── storage ├── tests ├── composer.json ├── composer.lock ├── docker.

Did you know that Docker Desktop now offers support for developers subscribed to a Pro or a Team plan? Click here to learn more.

This page contains information on how to diagnose and troubleshoot Docker Desktop issues, request Docker Desktop support (Pro and Team plan users only), send logs and communicate with the Docker Desktop team, use our forums and Success Center, browse and log issues on GitHub, and find workarounds for known problems.

Troubleshoot

Choose > Troubleshootfrom the menu bar to see the troubleshoot options.

The Troubleshoot page contains the following options:

  • Restart Docker Desktop: Select to restart Docker Desktop.

  • Support: Developers on Pro and Team plans can use this option to send a support request. Other users can use this option to diagnose any issues in Docker Desktop. For more information, see Diagnose and feedback and Support.

  • Reset Kubernetes cluster: Select this option to delete all stacks and Kubernetes resources. For more information, see Kubernetes.

  • Clean / Purge data: This option resets all Docker data without areset to factory defaults. Selecting this option results in the loss of existing settings.

  • Reset to factory defaults: Choose this option to reset all options onDocker Desktop to their initial state, the same as when Docker Desktop was first installed.

  • Uninstall: Choose this option to remove Docker Desktop from yoursystem.

Uninstall Docker Desktop from the command line

To uninstall Docker Desktop from a terminal, run: <DockerforMacPath>--uninstall. If your instance is installed in the default location, thiscommand provides a clean uninstall:

You might want to use the command-line uninstall if, for example, you find thatthe app is non-functional, and you cannot uninstall it from the menu.

Diagnose and feedback

In-app diagnostics

If you encounter problems for which you do not find solutions in thisdocumentation, on Docker Desktop issues onGitHub, or the Docker Desktop forum, we can help you troubleshootthe log data. Before reporting an issue, we recommend that you read the information provided on this page to fix some common known issues.

Note

Docker Desktop offers support for users subscribed to a Pro or a Team plan. If you are experiencing any issues with Docker Desktop, follow the instructions in this section to send a support request to Docker Support.

Before you get started, we recommend that you sign into your Docker Desktop application and your Docker Hub account.

  1. Choose > Troubleshoot.
  2. Sign into Docker Desktop. In addition, ensure you are signed into your Docker account.
  3. Click Get support. This opens the in-app Support page and starts collecting the diagnostics.
  4. When the diagnostics collection process is complete, click Upload to get a Diagnostic ID.
  5. When the diagnostics have been uploaded, Docker Desktop prints a diagnostic ID. Copy this ID.
  6. If you have subscribed to a Pro or a Team plan, click Contact Support. This opens the Docker Desktop support form. Fill in the information required and add the ID you copied earlier to the Diagnostics ID field. Click Submit to request Docker Desktop support.

    Note

    You must be signed in to Docker Desktop using your Pro or Team plan credentials to access the support form. For information on what’s covered as part of Docker Desktop support, see Support.

  7. If you are not subscribed to a Pro or a team plan, you can click Upgrade to benefit from Docker Support to upgrade your existing account. Alternatively, click Report a Bug to open a new Docker Desktop issue on GitHub. This opens Docker Desktop for Mac on GitHub in your web browser in a ‘New issue’ template. Complete the information required and ensure you add the diagnostic ID you copied earlier. Click submit new issue to create a new issue.

Diagnosing from the terminal

In some cases, it is useful to run the diagnostics yourself, for instance, ifDocker Desktop cannot start.

First, locate the com.docker.diagnose tool. If you have installed Docker Desktop in the Applications directory, then it is located at/Applications/Docker.app/Contents/MacOS/com.docker.diagnose.

To create and upload diagnostics, run:

After the diagnostics have finished, you should have the following output,containing your diagnostics ID:

The diagnostics ID (here BE9AFAAF-F68B-41D0-9D12-84760E6B8740/20190905152051) iscomposed of your user ID (BE9AFAAF-F68B-41D0-9D12-84760E6B8740) and a timestamp(20190905152051). Ensure you provide the full diagnostics ID, and not just the user ID.

Docker Php Composer

To view the contents of the diagnostic file, run:

Check the logs

In addition to using the diagnose and feedback option to submit logs, you canbrowse the logs yourself.

In a terminal

To watch the live flow of Docker Desktop logs in the command line, run the following script from your favorite shell.

Alternatively, to collect the last day of logs (1d) in a file, run:

In the Console app

Macs provide a built-in log viewer, named “Console”, which you can use to checkDocker logs.

The Console lives in /Applications/Utilities; you can search for it withSpotlight Search.

To read the Docker app log messages, type docker in the Console window search bar and press Enter. Then select ANY to expand the drop-down list next to your docker search entry, and select Process.

You can use the Console Log Query to search logs, filter the results in variousways, and create reports.

Troubleshooting

Support for Apple silicon processors

At the moment, Docker Desktop is compatible with Intel processors only. You can learn more about the technical preview for Apple silicon in our docs.

Make sure certificates are set up correctly

Docker Desktop ignores certificates listed under insecure registries, and doesnot send client certificates to them. Commands like docker run that attempt topull from the registry produces error messages on the command line, for example:

As well as on the registry. For example:

For more about using client and server side certificates, seeAdding TLS certificates in the Getting Started topic.

Volume mounting requires file sharing for any project directories outside of /Users

If you are using mounted volumes and get runtime errors indicating anapplication file is not found, access to a volume mount is denied, or a servicecannot start, such as when using Docker Compose,you might need to enable file sharing.

Volume mounting requires shared drives for projects that live outside of the/Users directory. Go to >Preferences > Resources > File sharing and share the drive that contains the Dockerfile and volume.

Incompatible CPU detected

Docker Desktop requires a processor (CPU) that supports virtualization and, morespecifically, the Apple Hypervisorframework.Docker Desktop is only compatible with Mac systems that have a CPU that supports the Hypervisor framework. Most Macs built in 2010 and later support it,as described in the Apple Hypervisor Framework documentation about supported hardware:

Generally, machines with an Intel VT-x feature set that includes Extended PageTables (EPT) and Unrestricted Mode are supported.

To check if your Mac supports the Hypervisor framework, run the following command in a terminal window.

If your Mac supports the Hypervisor Framework, the command printskern.hv_support: 1.

If not, the command prints kern.hv_support: 0.

See also, Hypervisor FrameworkReferencein the Apple documentation, and Docker Desktop Mac system requirements.

Docker Php Composer Not Found

Workarounds for common problems

  • If Docker Desktop fails to install or start properly on Mac:

    • Make sure you quit Docker Desktop before installing a new version of theapplication ( > Quit Docker Desktop). Otherwise, you get an “application in use” error when you try tocopy the new app from the .dmg to /Applications.

    • Restart your Mac to stop / discard any vestige of the daemon running fromthe previously installed version.

    • Run the uninstall commands from the menu.

  • If docker commands aren’t working properly or as expected, you may need tounset some environment variables, to make sure you are not using the legacyDocker Machine environment in your shell or command window. Unset theDOCKER_HOST environment variable and related variables. If you use bash, use the following command: unset ${!DOCKER_*}

  • For the hello-world-nginx example, Docker Desktop must be running to get tothe web server on http://localhost/. Make sure that the Docker icon isdisplayed on the menu bar, and that you run the Docker commands in a shell that is connected to the Docker Desktop Engine.Otherwise, you might start the webserver container but get a “web page notavailable” error when you go to localhost.

  • If you see errors like Bind for 0.0.0.0:8080 failed: port is alreadyallocated or listen tcp:0.0.0.0:8080: bind: address is already in use:

    • These errors are often caused by some other software on the Mac using thoseports.

    • Run lsof -i tcp:8080 to discover the name and pid of the other process anddecide whether to shut the other process down, or to use a different port inyour docker app.

Docker Php Composer Create

Known issues

  • IPv6 is not (yet) supported on Docker Desktop.

  • You might encounter errors when using docker-compose up with Docker Desktop(ValueError: Extra Data). We’ve identified this is likely related to dataand/or events being passed all at once rather than one by one, so sometimesthe data comes back as 2+ objects concatenated and causes an error.

  • Force-ejecting the .dmg after running Docker.app from it can cause thewhale icon to become unresponsive, Docker tasks to show as not responding inthe Activity Monitor, and for some processes to consume a large amount of CPUresources. Reboot and restart Docker to resolve these issues.

  • Docker does not auto-start on login even when it is enabled in > Preferences. This is related to aset of issues with Docker helper, registration, and versioning.

  • Docker Desktop uses the HyperKit hypervisor(https://github.com/docker/hyperkit) in macOS 10.10 Yosemite and higher. Ifyou are developing with tools that have conflicts with HyperKit, such asIntel Hardware Accelerated Execution Manager(HAXM),the current workaround is not to run them at the same time. You can pauseHyperKit by quitting Docker Desktop temporarily while you work with HAXM.This allows you to continue work with the other tools and prevent HyperKitfrom interfering.

  • If you are working with applications like ApacheMaven that expect settings for DOCKER_HOST andDOCKER_CERT_PATH environment variables, specify these to connect to Dockerinstances through Unix sockets. For example:

  • There are a number of issues with the performance of directories bind-mountedinto containers. In particular, writes of small blocks, and traversals of largedirectories are currently slow. Additionally, containers that perform largenumbers of directory operations, such as repeated scans of large directorytrees, may suffer from poor performance. Applications that behave in this wayinclude:

    • rake
    • ember build
    • Symfony
    • Magento
    • Zend Framework
    • PHP applications that use Composer to installdependencies in a vendor folder

    As a workaround for this behavior, you can put vendor or third-party librarydirectories in Docker volumes, perform temporary file system operationsoutside of bind mounts, and use third-party tools like Unison or rsync tosynchronize between container directories and bind-mounted directories. We areactively working on performance improvements using a number of differenttechniques. To learn more, see the topic on our roadmap.

Support

Docker Desktop offers support for developers subscribed to a Pro or a Team plan. Click here to upgrade your existing account.

This section contains instructions on how to get support, and covers the scope of Docker Desktop support.

How do I get Docker Desktop support?

If you have subscribed to a Pro and Team account, please raise a ticket through Docker Desktop support.

Docker Community users can get support through our Github repos for-win and for-mac, where we respond on a best-effort basis.

What support can I get?

If you are a Pro or a Team user, you can request for support on the following types of issues:

  • Desktop upgrade issues
  • Desktop installation issues
    • Installation crashes
    • Failure to launch Docker Desktop on first run
  • Usage issues
    • Crash closing software
    • Docker Desktop not behaving as expected
  • Configuration issues
  • Basic product ‘how to’ questions

What is not supported?

Docker Desktop excludes support for the following types of issues:

  • Use on or in conjunction with hardware or software other than that specified in the applicable documentation
  • Running on unsupported operating systems, including beta/preview versions of operating systems
  • Support for the Docker engine, Docker CLI, or other bundled Linux components
  • Support for Kubernetes
  • Features labeled as experimental
  • System/Server administration activities
  • Supporting Desktop as a production runtime
  • Scale deployment/multi-machine installation of Desktop
  • Routine product maintenance (data backup, cleaning disk space and configuring log rotation)
  • Third-party applications not provided by Docker
  • Altered or modified Docker software
  • Defects in the Docker software due to hardware malfunction, abuse, or improper use
  • Any version of the Docker software other than the latest version
  • Reimbursing and expenses spent for third-party services not provided by Docker
  • Docker Support excludes training, customization, and integration

What versions are supported?

We currently only offer support for the latest version of Docker Desktop. If you are running an older version, you may be asked to upgrade before we investigate your support request.

How many machines can I get support for Docker Desktop on?

As a Pro user you can get support for Docker Desktop on a single machine.As a Team, you can get support for Docker Desktop for the number of machines equal to the number of seats as part of your plan.

What OS’s are supported?

Docker Desktop is available for Mac and Windows. The supported version information can be found on the following pages:

Can I run Docker Desktop on Virtualized hardware?

No, currently this is unsupported and against the terms of use.

mac, troubleshooting, logs, issues
  • Installation & Setup
  • Executing Commands
  • Interacting With Databases
  • Running Tests

Introduction

Laravel Sail is a light-weight command-line interface for interacting with Laravel's default Docker development environment. Sail provides a great starting point for building a Laravel application using PHP, MySQL, and Redis without requiring prior Docker experience.

At its heart, Sail is the docker-compose.yml file and the sail script that is stored at the root of your project. The sail script provides a CLI with convenient methods for interacting with the Docker containers defined by the docker-compose.yml file.

Laravel Sail is supported on macOS, Linux, and Windows (via WSL2).

Docker Php Composer Plugin

Installation & Setup

Laravel Sail is automatically installed with all new Laravel applications so you may start using it immediately. To learn how to create a new Laravel application, please consult Laravel's installation documentation for your operating system. During installation, you will be asked to choose which Sail supported services your application will be interacting with.

Installing Sail Into Existing Applications

If you are interested in using Sail with an existing Laravel application, you may simply install Sail using the Composer package manager. Of course, these steps assume that your existing local development environment allows you to install Composer dependencies:

After Sail has been installed, you may run the sail:install Artisan command. This command will publish Sail's docker-compose.yml file to the root of your application:

Finally, you may start Sail. To continue learning how to use Sail, please continue reading the remainder of this documentation:

Configuring A Bash Alias

By default, Sail commands are invoked using the vendor/bin/sail script that is included with all new Laravel applications:

However, instead of repeatedly typing vendor/bin/sail to execute Sail commands, you may wish to configure a Bash alias that allows you to execute Sail's commands more easily:

Once the Bash alias has been configured, you may execute Sail commands by simply typing sail. The remainder of this documentation's examples will assume that you have configured this alias:

Starting & Stopping Sail

Laravel Sail's docker-compose.yml file defines a Docker variety of containers that work together to help you build Laravel applications. Each of these containers is an entry within the services configuration of your docker-compose.yml file. The laravel.test container is the primary application container that will be serving your application.

Before starting Sail, you should ensure that no other web servers or databases are running on your local computer. To start all of the Docker containers defined in your application's docker-compose.yml file, you should execute the up command:

To start all of the Docker containers in the background, you may start Sail in 'detached' mode:

Once the application's containers have been started, you may access the project in your web browser at: http://localhost.

To stop all of the containers, you may simply press Control + C to stop the container's execution. Or, if the containers are running in the background, you may use the down command:

Executing Commands

When using Laravel Sail, your application is executing within a Docker container and is isolated from your local computer. However, Sail provides a convenient way to run various commands against your application such as arbitrary PHP commands, Artisan commands, Composer commands, and Node / NPM commands.

When reading the Laravel documentation, you will often see references to Composer, Artisan, and Node / NPM commands that do not reference Sail. Those examples assume that these tools are installed on your local computer. If you are using Sail for your local Laravel development environment, you should execute those commands using Sail:

Executing PHP Commands

PHP commands may be executed using the php command. Of course, these commands will execute using the PHP version that is configured for your application. To learn more about the PHP versions available to Laravel Sail, consult the PHP version documentation:

Executing Composer Commands

Composer commands may be executed using the composer command. Laravel Sail's application container includes a Composer 2.x installation:

Installing Composer Dependencies For Existing Applications

If you are developing an application with a team, you may not be the one that initially creates the Laravel application. Therefore, none of the application's Composer dependencies, including Sail, will be installed after you clone the application's repository to your local computer.

You may install the application's dependencies by navigating to the application's directory and executing the following command. This command uses a small Docker container containing PHP and Composer to install the application's dependencies:

Executing Artisan Commands

Laravel Artisan commands may be executed using the artisan command:

Executing Node / NPM Commands

Node commands may be executed using the node command while NPM commands may be executed using the npm command:

Interacting With Databases

MySQL

As you may have noticed, your application's docker-compose.yml file contains an entry for a MySQL container. This container uses a Docker volume so that the data stored in your database is persisted even when stopping and restarting your containers. In addition, when the MySQL container is starting, it will ensure a database exists whose name matches the value of your DB_DATABASE environment variable.

Once you have started your containers, you may connect to the MySQL instance within your application by setting your DB_HOST environment variable within your application's .env file to mysql.

To connect to your application's MySQL database from your local machine, you may use a graphical database management application such as TablePlus. By default, the MySQL database is accessible at localhost port 3306.

Redis

Your application's docker-compose.yml file also contains an entry for a Redis container. This container uses a Docker volume so that the data stored in your Redis data is persisted even when stopping and restarting your containers. Once you have started your containers, you may connect to the Redis instance within your application by setting your REDIS_HOST environment variable within your application's .env file to redis.

To connect to your application's Redis database from your local machine, you may use a graphical database management application such as TablePlus. By default, the Redis database is accessible at localhost port 6379.

MeiliSearch

If you chose to install the MeiliSearch service when installing Sail, your application's docker-compose.yml file will contain an entry for this powerful search-engine that is compatible with Laravel Scout. Once you have started your containers, you may connect to the MeiliSearch instance within your application by setting your MEILISEARCH_HOST environment variable to http://meilisearch:7700.

From your local machine, you may access MeiliSearch's web based administration panel by navigating to http://localhost:7700 in your web browser.

Running Tests

Laravel provides amazing testing support out of the box, and you may use Sail's test command to run your applications feature and unit tests. Any CLI options that are accepted by PHPUnit may also be passed to the test command:

The Sail test command is equivalent to running the test Artisan command:

Laravel Dusk

Laravel Dusk provides an expressive, easy-to-use browser automation and testing API. Thanks to Sail, you may run these tests without ever installing Selenium or other tools on your local computer. To get started, uncomment the Selenium service in your application's docker-compose.yml file:

Next, ensure that the laravel.test service in your application's docker-compose.yml file has a depends_on entry for selenium:

Finally, you may run your Dusk test suite by starting Sail and running the dusk command:

Previewing Emails

Laravel Sail's default docker-compose.yml file contains a service entry for MailHog. MailHog intercepts emails sent by your application during local development and provides a convenient web interface so that you can preview your email messages in your browser. When using Sail, MailHog's default host is mailhog and is available via port 1025:

When Sail is running, you may access the MailHog web interface at: http://localhost:8025

Container CLI

Sometimes you may wish to start a Bash session within your application's container. You may use the shell command to connect to your application's container, allowing you to inspect its files and installed services as well execute arbitrary shell commands within the container:

To start a new Laravel Tinker session, you may execute the tinker command:

PHP Versions

Docker Php Composer

Sail currently supports serving your application via PHP 8.0 or PHP 7.4. To change the PHP version that is used to serve your application, you should update the build definition of the laravel.test container in your application's docker-compose.yml file:

Docker Php Composer Private Repository

In addition, you may wish to update your image name to reflect the version of PHP being used by your application. This option is also defined in your application's docker-compose.yml file:

After updating your application's docker-compose.yml file, you should rebuild your container images:

Sharing Your Site

Sometimes you may need to share your site publicly in order to preview your site for a colleague or to test webhook integrations with your application. To share your site, you may use the share command. After executing this command, you will be issued a random laravel-sail.site URL that you may use to access your application:

If you would like to choose the subdomain for your shared site, you may provide the subdomain option when executing the share command:

Docker Php Composer

{tip} The share command is powered by Expose, an open source tunneling service by BeyondCode.

Customization

Since Sail is just Docker, you are free to customize nearly everything about it. To publish Sail's own Dockerfiles, you may execute the sail:publish command:

After running this command, the Dockerfiles and other configuration files used by Laravel Sail will be placed within a docker directory in your application's root directory. After customizing your Sail installation, you may rebuild your application's containers using the build command: