Using Docker to build lamp environment on Mac system _docker

Source: Internet
Author: User
Tags commit redis docker ps docker run docker toolbox install redis

Objective

Docker finally came out of the Mac version, hurriedly to download, installation steps, before the Mac version of the time to install Docker Toolbox, now directly download installation is good.

The way it's installed.


Status bar

Tips for Docker

At this point, you can enter the Docker command inside the terminal.

$ docker--version
Docker version 1.13.0-rc3, build 4d92237
$ docker-compose--version
Version 1.9.0, build 2585387
$ docker-machine--version
docker-machine version 0.9.0-rc2, build 7b19591

If you enter the Docker prompt in the terminal is command not found please add Docker to environment variable

Vim/etc/profile
last inserted Export Path=${path}:/usr/local/bin # # Docker command installed to this directory

Hello World

Docker Run Hello-world

It is mainly used to test whether the Docker is installed and can be used normally.


Hello World

docker images Viewing mirrors that have already been downloaded

docker psView the containers that are running

docker ps -aTo view all running containers

View first-use containers

Remove mirrors and containers (in order to understand what mirroring is and what is a container, I think, mirroring is a computer that has nothing to do with shutting down, and a container is a computer that installs the software that is needed to run)

docker rm Delete Container

docker rmi Remove Mirror

docker rmi c54a2cc56cbbThe Hello-world mirror will be deleted.

docker rmi c5Also deletes the Hello-world mirror image because C5 can represent a unique mirror image in your mirror list, Docker will help you to complete it automatically.

LAMP

Find the Ubuntu version inside hub.docker.com

Docker search Ubuntu

Install Ubuntu

Docker pull Ubuntu # The Ubuntu version installed is 16.04
Docker pull ubuntu:14.04 # ubuntu 14.04 version

Enter Ubuntu container, install software

Docker run <image id>-i-t/bin/bash #-I synchronous input-t synchronous output-D continued
to run and then went into the familiar Ubuntu
installation vim apache2 MySQL php5 r Edis
apt-get Update 
apt-get install vim
apt-get install
apache2 apt-get Install Apt-get install php5 libapache2-mod-php5 php5-gd php5-mysql apt-get install redis-server Php5-redis

Exit Exit Bash after Setup completes and the current container stops

If you add parameters at run time, -d you can go through attach and exec again in the container.

Docker attach-i-T <container id>/bin/bash Docker exec-i-
t <container id>/bin/bash

Use docker ps -a to view the current container

The containers we just finished need to be stored in a mirror image, or we need to install the software every time we use this container, use the commit command

Docker commit-m "description" <container id> new_name

Again, docker images you'll find that the images that you just submitted appears in the list.

Map local port to container Port map local folder to container folder

Docker run-itd-p 8989:80-v/users/php/wwwroot:/var/www/html 74b3eadeafea/bin/bash

-P Maps The local 8989 port to the container's 80 port

-V Map local folders to server Apache Default Web site Directory

Upload your own image to hub.docker.com.

First to docker.com registered account, a new REPOSITORY

Docker Login # Login Docker
docker tag <images id> <namespace>/<image name>:<version tag eg LATEST&G t;
Docker push <namsoace>/<image name> # Wait for the upload to be done

Upload tags.

Summarize

The above is the entire content of this article, I hope the content of this article for everyone's study or work can bring certain help, if you have questions you can message exchange.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.