容器是 应用层的抽象 ,是标准化的单元,容器内部不包含 操作系统 的细节和内容,比虚拟机 轻量
开发:简化开发环境的搭建; 运维 :交付系统更为流畅,伸缩性更好
$ docker search mongo NAME DESCRIPTION STARS OFFICIAL AUTOMATED mongo MongoDB document databases provide high avai… 6196 [OK] mongo-express Web-based MongoDB admin interface, written w… 516 [OK] tutum/mongodb MongoDB Docker image – listens in port 27017… 228 [OK] ...
$ docker pull mongo Using default tag: latest latest: Pulling from library/mongo Digest: sha256:d9e20d05063ba34bac4da916e335c70d6add38241cee1e99ad96c47660bd6955 Status: Image is up to date for mongo:latest docker.io/library/mongo:latest
docker images REPOSITORY TAG IMAGE ID CREATED SIZE mongo latest cdc6740b66a7 4 weeks ago 361MB zookeeper latest 4ebfb9474e72 5 months ago 150MB mysql latest 7bb2586065cd 5 months ago 477MB ...
$ docker run -d --name mongo -p 27017:27017 -v ~/docker-data/mongo:/data/db -e MONGO_INITDB_ROOT_USERNAME=root -e MONGO_INITDB_ROOT_PASSWORD=123456 mongo 19fcb168261d63aa094ed79b7d93d997f1b58330537fc76bd1bebf24f8cbee1f
$ docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 19fcb168261d mongo "docker-entrypoint.s…" 6 minutes ago Up 6 minutes 0.0.0.0:27017->27017/tcp mongo
$ docker exec -it mongo /bin/bash root@19fcb168261d:/# mongo -uroot -p123456 MongoDB shell version v4.2.0 connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb Implicit session: session { "id" : UUID("9413b54e-cf03-4951-9dbb-8e069565a503") } MongoDB server version: 4.2.0 Welcome to the MongoDB shell. > show dbs admin 0.000GB config 0.000GB local 0.000GB