docker pull nignx 搜索nginx
有时候会出错,可能上次没有正常退出docker
service docker restart
启动就可以了

 docker pull nginx
Using default tag: latest
latest: Pulling from library/nginx
a2abf6c4d29d: Pull complete
a9edb18cadd1: Pull complete
589b7251471a: Pull complete
186b1aaa4aa6: Pull complete
b4df32aa5a72: Pull complete
a0bcbecc962e: Pull complete
Digest: sha256:0d17b565c37bcbd895e9d92315a05c1c3c9a29f762b011a10c54a66cd53c9b31
Status: Downloaded newer image for nginx:latest
docker.io/library/nginx:latest
#查看都有什么镜像
[root@localhost ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED        SIZE
nginx        latest    605c77e624dd   3 days ago     141MB
centos       latest    5d0da3dc9764   3 months ago   231MB
#启动nginx  docker run  -d --name  nginx01  -p 3344:80 nginx 从后台启动 名字nginx01 开放3344 端口 
[root@localhost ~]#docker run  -d --name  nginx01  -p 3344:80 nginx
 c573c26245340de7726c54e2ea3dd7e047789203922725e2795b3bf40bd32fab
[root@localhost ~]# docker ps 查看
CONTAINER ID   IMAGE     COMMAND                  CREATED          STATUS         PORTS                                   NAMES
c573c2624534   nginx     "/docker-entrypoint.…"   17 seconds ago   Up 9 seconds   0.0.0.0:3344->80/tcp, :::3344->80/tcp   nginx01
[root@localhost ~]# curl localhost:3344查看本机端口
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
 
<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>
 
<p><em>Thank you for using nginx.</em></p>
</body>
 

进入nginx 容器

[root@localhost ~]# docker exec -it nginx01 /bin/bash

root@c573c2624534:/# whereis nginx 查看nginx的配置文件,配置文件在/etc/nginx

root@c573c2624534:/# cd /etc/nginx/

root@c573c2624534:/etc/nginx# ls 查看nginx 配置文件

conf.d  fastcgi_params  mime.types  modules  nginx.conf  scgi_params  uwsgi_params

root@c573c2624534:/etc/nginx#

退出nginx 容器

root@c573c2624534:/etc/nginx# exit
exit
[root@localhost ~]# docker ps 查看
CONTAINER ID   IMAGE     COMMAND                  CREATED          STATUS          PORTS                                   NAMES
c573c2624534   nginx     "/docker-entrypoint.…"   12 minutes ago   Up 12 minutes   0.0.0.0:3344->80/tcp, :::3344->80/tcp   nginx01
[root@localhost ~]# docker stop nginx01 关闭容器
nginx01
[root@localhost ~]# docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES

官方使用 docker run -it --rm tomact :9.0
#我们之前的启动都是后台启动,停止了容器,容器还是可以查到,docker run -it --rm .用来测试。用完就删除

[root@localhost ~]# docker pull tomcat:9.0
9.0: Pulling from library/tomcat
Digest: sha256:cd96d4f7d3f5fc4d3bc1622ec678207087b8215d55021a607ecaefba80b403ea
Status: Image is up to date for tomcat:9.0
docker.io/library/tomcat:9.0
 
 #查看镜像
 [root@localhost ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED        SIZE
nginx        latest    605c77e624dd   3 days ago     141MB
tomcat       9.0       b8e65a4d736d   10 days ago    680MB
centos       latest    5d0da3dc9764   3 months ago   231MB
[root@localhost ~]# docker run -d -p 3355:8080 --name tomcat01 #后面要跟容器的型号
"docker run" requires at least 1 argument.
See 'docker run --help'.
 
Usage:  docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
 
Run a command in a new container
[root@localhost ~]# docker run -d -p 3355:8080 --name tomcat01 tomcat
Unable to find image 'tomcat:latest' locally
latest: Pulling from library/tomcat
0e29546d541c: Already exists
9b829c73b52b: Already exists
cb5b7ae36172: Already exists
6494e4811622: Already exists
668f6fcc5fa5: Already exists
dc120c3e0290: Already exists
8f7c0eebb7b1: Already exists
77b694f83996: Already exists
0f611256ec3a: Pull complete
4f25def12f23: Pull complete
Digest: sha256:9dee185c3b161cdfede1f5e35e8b56ebc9de88ed3a79526939701f3537a52324
Status: Downloaded newer image for tomcat:latest
68b62dedcb74ab594565e740eddba1aa522ba14e3112b20d0f38d1aa476be353
 
[root@localhost ~]# docker exec -it tomcat01 /bin/bash
root@68b62dedcb74:/usr/local/tomcat# ls
BUILDING.txt     LICENSE  README.md      RUNNING.txt  conf  logs            temp     webapps.dist
CONTRIBUTING.md  NOTICE   RELEASE-NOTES  bin          lib   native-jni-lib  webapps  work
发现问题,linux命令少了没有webbapps   阿里云镜像的原因,所有有不必要的都剔掉,

部署es +kiibana

docker run -d --name elasticsearch -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" elasticsearch:tag
 
ES_JAVA_OPTS="-Xms64m -Xms120m" 限制其内存使用
docker run -d --name elasticsearch -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -e ES_JAVA_OPTS="-Xms64m -Xms120m" elasticsearch:7.6.2
[root@localhost ~]# docker run -d --name elasticsearch02 -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -e ES_JAVA_OPTS="-Xms64m -Xms120m" elasticsearch:7.6.2
bd2c126529c619d93dfd9ad40f9605b81395d413efce49eb392cd1d23c77f5f5
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# docker ps
CONTAINER ID   IMAGE                 COMMAND                  CREATED              STATUS              PORTS                                                                                  NAMES
bd2c126529c6   elasticsearch:7.6.2   "/usr/local/bin/dock…"   About a minute ago   Up About a minute   0.0.0.0:9200->9200/tcp, :::9200->9200/tcp, 0.0.0.0:9300->9300/tcp, :::9300->9300/tcp   elasticsearch02
[root@localhost ~]# docker stats
CONTAINER ID   NAME      CPU %     MEM USAGE / LIMIT   MEM %     NET I/O   BLOCK I/O   PIDS
               --        --        -- / --             --        --        --          --
CONTAINER ID   NAME      CPU %     MEM USAGE / LIMIT   MEM %     NET I/O   BLOCK I/O   PIDS
               --        --        -- / --             --        --        --          --
CONTAINER ID   NAME      CPU %     MEM USAGE / LIMIT   MEM %     NET I/O   BLOCK I/O   PIDS
   --        --        -- / --             --        --        --          --
CONTAINER ID   NAME              CPU %     MEM USAGE / LIMIT   MEM %     NET I/O       BLOCK I/O         PIDS
bd2c126529c6   elasticsearch02   0.60%     239MiB / 486.8MiB   49.10%    7.84kB / 0B   2.03GB / 7.04MB   26
CONTAINER ID   NAME              CPU %     MEM USAGE / LIMIT   MEM %     NET I/O       BLOCK I/O         PIDS
bd2c126529c6   elasticsearch02   0.60%     239MiB / 486.8MiB   49.10%    7.84kB / 0B   2.03GB / 7.04MB   26
CONTAINER ID   NAME              CPU %     MEM USAGE / LIMIT   MEM %     NET I/O       BLOCK I/O         PIDS
bd2c126529c6   elasticsearch02   0.60%     239MiB / 486.8MiB   49.10%    7.84kB / 0B   2.03GB / 7.04MB   26
CONTAINER ID   NAME              CPU %     MEM USAGE / LIMIT   MEM %     NET I/O       BLOCK I/O         PIDS
bd2c126529c6   elasticsearch02   0.60%     239MiB / 486.8MiB   49.10%    7.84kB / 0B   2.03GB / 7.04MB   26
[root@localhost ~]# curl localhost:9200
{
  "name" : "bd2c126529c6",
  "cluster_name" : "docker-cluster",
  "cluster_uuid" : "-GZxS3uMRvC4lApjLkt2Pw",
  "version" : {
    "number" : "7.6.2",
    "build_flavor" : "default",
    "build_type" : "docker",
    "build_hash" : "ef48eb35cf30adf4db14086e8aabd07ef6fb113f",
    "build_date" : "2020-03-26T06:34:37.794943Z",
    "build_snapshot" : false,
    "lucene_version" : "8.4.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}
[root@localhost ~]#