Loading...
「ツール」は右上に移動しました。
利用したサーバー: natural-voltaic-titanium
13いいね 3956回再生

Docker 101: Building your own LAMP Stack

New to Docker?

Here is a tutorial about how to create your very own LAMP Stack:
Ubuntu
Apache2
MySQL
PHP

Steps:
Build Docker image
Run Container
Connecting to container

After spending more time with docker and hearing feedback on the way that I used to setup docker. I was shown why my old knowledge of docker was flawed and I was able to grow and learn how to properly use docker. Granted that most of the other docker videos that I have created were after I have learned the proper ways of docker. But with that said, let's setup our LAMP Stack the proper way

The first thing we would want to do is create our mysql database as it's own standalone instance, this is because we can have multiple containers linked to the same database instance.

$ docker run --name mysql-5.7 -e MYSQL_ROOT_PASSWORD=password -d mysql:5.7

The next part would to create our Apache with PHP image. At this point, we would want to make sure that we have the configuration files needed for Apache and PHP so that they can override the default configurations from the repository. We will base our image on Ubuntu, and then from there, we would install each of the packages that we need in order to run our web page, such as PHP and Apache. Also, we should enable the needed apache modules and custom vhost

Since we are running an Apache service, we would want to expose port 80 and 443. For the command, we will have the image execute a custom script. The script will start apache and then use the 'bash' command to prevent the container from shutting down.

We will build the docker images. If there are any issues, we can update the docker file and then rebuild the image again

$ docker build -t wordpressguide:1.0.0 .

Once we have succefuly build our image, then we can use the docker run command to link our container to our databaseas well as the location of the codebase

$ docker run -dit --name wordpressguide-dev --link mysql-5.7:wpdb -v /var/www/sites/WordPress_Tutorial:/var/www/sites/WordPress_Tutorial wordpress:1.0.0

Make sure to inspect the docker container and added the needed host entry so that you can see the site running under the docker container

Musical Selections:
Nsolo - Breathe
Nsolo - Exile
Nsolo - Hush
Please check out his channel at:    / @nsolo   and soundcloud.com/nsolo

More Docker Videos:
Assign Static IP to Docker Containers:    • Docker 101: How To Assign Static IP to Doc...  
A better way to run Docker on Windows:    • Solution to the Windows 10 + Docker Issue  
Linking Docker Containers:    • Docker 101: Linking Containers  

コメント