Docker
Docker Desktop
Docker Desktop is a native application that delivers all of the Docker tools to your Mac or Windows Computer.
Open Docker Desktop. (Download here if you don't have it).
Type the following command in your terminal:
docker run -dp 80:80 docker/getting-started
Open your browser to http://localhost
Have fun!
The Docker Dashboard
What is a container
a container is simply another process on your machine that has been isolated from all other processes on the host machine.
What is a container image?
When running a container, it uses an isolated filesystem. This custom filesystem is provided by a container image. Since the image contains the container's filesystem, it must contain everything needed to run an application - all dependencies, configuration, scripts, binaries, etc. The image also contains other configuration for the container, such as environment variables, a default command to run, and other metadata.
Create a Repo
To push an image, we first need to create a repo on Docker Hub.
Go to Docker Hub and log in if you need to.
Click the Create Repository button.
For the repo name, use
getting-started
. Make sure the Visibility isPublic
.Click the Create button!
Pushing our Image
$ docker push docker/getting-started
Persisting our DB
The Container's Filesystem
Container Volumes
docker volume create todo-db
Play with Docker
Play with Docker is an interactive playground that allows you to run Docker commands on a linux terminal, no downloads required.
Log into https://labs.play-with-docker.com/ to access your PWD terminal
Type the following command in your PWD terminal:
docker run -dp 80:80 docker/getting-started:pwd
Wait for it to start the container and click the port 80 badge
Have fun!
Docker install Mysql
docker search mysql
docker pull mysql
docker images
docker rmi images
docker run images
docker run -p 3307:3306 --name mysql03 -e MYSQLROOTPASSWORD=123456 -d mysql
docker stop container
docker start container
docker rm container
Docker install Tomcat
docker pull tomcat
docker run -d -p 8080:8080 tomcat
docker logs containerID
Docker Commands
Starting an App container
docker run -d -p 80:80 docker/getting-started
Building a new container image
docker build -t getting-started .
Get the ID of the container
docker ps
stop the container
docker stop <the-container-id>
remove the container
docker rm <the-container-id>
Push image
docker push docker/getting-started
give the getting-started
image a new name
docker tag getting-started YOUR-USER-NAME/getting-started
Where is Docker actually storing my data when I use a named volume?
docker volume inspect todo-db
Appendix
Docker Home Page
https://www.docker.com/get-started
Docker Hub
Play With Docker
https://labs.play-with-docker.com/
评论