How to install Docker and deploy a LAMP Stack

Traducciones al Español
Estamos traduciendo nuestros guías y tutoriales al Español. Es posible que usted esté viendo una traducción generada automáticamente. Estamos trabajando con traductores profesionales para verificar las traducciones de nuestro sitio web. Este proyecto es un trabajo en curso.
Deprecated

This guide has been deprecated and is no longer being maintained.

Create a Linode account to try this guide with a $100 credit.
This credit will be applied to any valid services used during your first 60 days.

Docker is a container platform for applications. With Docker, users can download pre-configured apps without the hassle of the installation and configuration process. Docker containers can also build on each other.

If you are familiar with Docker containers, also try Linode Images to capture and deploy larger system profiles.

Install Prerequisites

Due to a known issue with the dependencies of the docker .deb, installing docker on a Debian/Ubuntu VM requires an additional step:

  1. Run:

     apt-get install dmsetup && dmsetup mknodes
    

Install Docker

Use the Docker-maintained install script for Debian or Ubuntu. For other operating systems, see the Docker Installation guides.

  1. Run:

    curl -sSL https://get.docker.com/ | sh
    
    Note

    The current version of the docker script checks for AUFS support and displays the warning below if support is not found:

    Warning: current kernel is not supported by the linux-image-extra-virtual package. We have no AUFS support. Consider installing the packages linux-image-virtual kernel and linux-image-extra-virtual for AUFS support. + sleep 10

    This message can be safely ignored, as the script will continue the installation using DeviceMapper or OverlayFS. If you require AUFS support, you will need to configure a distribution supplied or custom compiled kernel.

  2. If necessary, add the non-root user to the “docker” group:

    sudo usermod -aG docker example_user
    

Download the Docker Lamp Image

The Docker Hub user page for Linode can be accessed here. Select the lamp image for configuration information.

  1. Search for linode user images:

    sudo docker search linode
    
  2. Download the linode/lamp image:

    sudo docker pull linode/lamp
    

Run the Docker Container, Apache, and MySQL

When an image downloads, there are no image containers running.

  1. Run, create, or turn on a new container and forward port 80:

    sudo docker run -p 80:80 -t -i linode/lamp /bin/bash
    
    Caution
    This command also changes the terminal prompt to the root user within the new container.
  2. As the container’s root user, start Apache:

    service apache2 start
    
  3. Start MySQL:

    service mysql start
    
  4. Exit the container while leaving it running by pressing ctrl + p then ctrl + q.

  5. Enter the IP address in a web browser to test the site.

    Note
    The website’s root directory is /var/www/example.com/public_html/.

Congratulations, you have installed a configured LAMP stack using Docker!

Where to Find Configuration Settings

The LAMP image was installed using the Hosting a Website guide on a Ubuntu container. The configuration files and settings can be found there, or on the Docker Hub linode/lamp page.

More Information

You may wish to consult the following resources for additional information on this topic. While these are provided in the hope that they will be useful, please note that we cannot vouch for the accuracy or timeliness of externally hosted materials.

This page was originally published on


Your Feedback Is Important

Let us know if this guide made it easy to get the answer you needed.


Join the conversation.
Read other comments or post your own below. Comments must be respectful, constructive, and relevant to the topic of the guide. Do not post external links or advertisements. Before posting, consider if your comment would be better addressed by contacting our Support team or asking on our Community Site.