安装是千万不要开启啥window的功能

查看镜像

  • docker images

删除容器

  • docker rm -f $(docker ps -qa)

进入容器命令行

  • docker exec -it ${NAMES} /bin/bash

查看容器

  • docker ps -a

  • 正真运行的是容器,容器启动有专门的命令配置的

停止运行的容器

  • docker kill

删除容器

  • docker rm

启动所有容器

  • docker start $(docker ps -a | awk '{ print $1}' | tail -n +2)

ip地址

  • docker inspect --format='{{.NetworkSettings.IPAddress}}' ID/NAMES

docker 迁移

提交容器修改到镜像

docker commit -m "nginx config" nginx nginx:z1

导出镜像

docker save -o F:/nginx_z1.tar nginx:z1

导入镜像

docker load < F:/nginx_z1.tar

换下载源

docker-machine ssh
sudo vi /var/lib/boot2docker/profile
--label provider=virtualbox的下一行添加:

--registry-mirror=https://p31wiatp.mirror.aliyuncs.com/
--registry-mirror=http://hub-mirror.c.163.com/
--registry-mirror=https://registry.docker-cn.com/
--registry-mirror=https://docker.mirrors.ustc.edu.cn/

# 推出
exit;

# 重启docker
docker-machine.exe restart

docker-compose

version: "2.2"
services:
    mysql:
        image: mysql:5.7
        environment:
            MYSQL_ROOT_PASSWORD: "123456"
        command: [
            '--sql-mode=NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE'
        ]
        ports:
            - "3306:3306"
    php-fpm:
        image: php-fpm:z1.1
        volumes:
            - ~/work:/home/wwwroot
        ports:
            - "9000:9000"
        dns:
            - 8.8.8.8
            - 8.8.4.4
        environment:
            PHP_INI_PATH: "/home/wwwroot/php.ini"
            PHP_POOL_PATH: "/home/wwwroot/pool.conf"
    php-fpm56:
        image: crunchgeek/php-fpm:5.6-latest
        volumes:
            - ~/work:/home/wwwroot
        ports:
            - "9010:9010"
        dns:
            - 8.8.8.8
            - 8.8.4.4
        environment:
            PHP_INI_PATH: "/home/wwwroot/php.ini"
            PHP_POOL_PATH: "/home/wwwroot/pool.conf"
    nginx:
        image: nginx:z1
        volumes:
            - ~/work:/home/wwwroot
        ports:
            - "80:80"
        links:
            - php-fpm:php-fpm
            - php-fpm56:php-fpm56
    redis:
        image: redis:latest
        ports:
            - "6379:6379"
    memcached:
        image: memcached:latest
        ports:
            - "11211:11211"

Dockerfile

-- Dockerfile 文件

FROM openjdk:8-slim
RUN mkdir /work
RUN echo "hello world" > /work/greeting.log
VOLUME /work
ENV TZ=Asia/Shanghai
RUN set -eux; \
    ln -snf /usr/share/zoneinfo/$TZ /etc/localtime; \
    echo $TZ > /etc/timezone
EXPOSE 8097
ENTRYPOINT ["java","-jar","/work/eip.jar"]

-- VOLUME /work 挂载目录, 须要启动是指定本地文件目录 如 docker run -v ~/work/test:/word java:v8
-- 将dockerfile文件制作为image docker build -t java:v8 .

docker-compose 固定ip

version: "2.2"
services:
    redis:
        image: redis:latest
        ports:
            - "6379:6379"
        networks:
            proxy:
                ipv4_address: 172.16.0.6
    activemq:
        image: est412/apache-activemq-5.13.4:latest
        ports:
            - "61616:61616"
        networks:
            proxy:
                ipv4_address: 172.16.0.2
    java-more:
        image: openjdk:8-slim
        volumes:
            - /home/work:/home/wwwroot
        networks:
            proxy:
                ipv4_address: 172.16.0.3
        ports:
            - "8761:8761"
            - "8005:8005"
            - "8004:8004"
            - "8003:8003"
            - "8002:8002"
            - "8001:8001"
        command: >
            sh -c "sh /home/wwwroot/start.sh"
networks:
  proxy:
    ipam:
      config:
      - subnet: 172.16.0.0/24

posted on 2020-02-04 17:20  零度91  阅读(213)  评论(0编辑  收藏  举报