zoukankan      html  css  js  c++  java
  • docker mac

    官网上有安装方法。已安装成功。

    容器千万不能随便删 

    现在已经不用boot2docker,使用dockertools来安装docker,dockertools中包含docker-machine,等等。

    1、下载镜像

    docker pull ubuntu:12.04

    2、创建容器

    docker run -t -i ubuntu:12.04 /bin/bash   这种情况下exit之后,container会关闭

    3、退出容器

    exit

    4、列出镜像

    docker images

    5、列出容器

    docker ps 

    -a 未运行的

    -l 最后一次启动的

    6、删除镜像

    docker rmi -f image_id

    7、创建新的镜像

    docker commit new_image

    8、将镜像导出到本地

    docker save -o ubuntu_12.02.tar ubuntu:12.04

    9、本地文件导入到镜像

    docker load < ubuntu_12.02.tar

    10、在后台启动容器: 一定要写后面那些

    docker run -d ubuntu:12.04 /bin/sh -c "while true; do echo hello world; sleep 1; done"  这种情况下 exit container不会退出

    11、查找镜像:在网上查

    docker search image_id

    12、查看镜像或容器的参数

    docker inspect ubuntu:12.04

    13、端口访问和容器互联 还没看

    docker run -p 8080:80 -t -i ubuntu:12.04 /bin/bash  这样写是正确地。

    mac下外部容器无法访问docker?容器与docker相互访问,有其他方法。

    原因:需要在mac下装个vm,docker在vm下运行,mac-vm-docker,所以localhost:8080无法访问docker。

    检测办法:在ubuntu中安装w3m, w3m http://localhost:80,在容器内访问apache

           网上有很多教程,说要装boot2docker,但这个已经不推荐了,现在是使用docker-machine

           docker-machine:http://docs.docker.com/engine/installation/mac/

         使用docker-machine ip:8080来访问容器的apache2

    14、进入容器

    docker exec -it 0b17953a8f9e /bin/bash

    15、apache2ctl -k start

    apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2 for ServerName
    httpd (pid 2960) already running

    16、mysql root pw:root

    17、docker中的images和container

    images:
    ubuntu:latest 删不掉,被其他容器使用
    ubuntu/mysql 在14.04的基础上安装了mysql
    ubuntu/php-all 在ubuntu/mysql的基础上安装了,Apache,php,phpmyadmin,测试成功 container: 7c90c9eb42f9: 在14.04的基础上安装了mysql,Apache,php,phpmyadmin,测试成功

    容器和主机相互拷文件

    docker cp foo.txt mycontainer:/foo.txt
    docker cp mycontainer:/foo.txt foo.txt

    之前在mac下安装docker,需要在VM下运行docker,在mac 的terminal中运行docker的命令

    现在docker支持mac了,所以需要重新装下。

    会出现一个问题:docker: Error response from daemon: client is newer than server (client API version: 1.24, server API version: 1.21).

    解决办法:docker-machine upgrade;  在 mac terminal中

    官网地址:https://docs.docker.com/docker-for-mac/

  • 相关阅读:
    int **指针问题
    用 _tcscmp 替代 strcmp 或 wcscmp
    C++经典面试算法题
    目标世界上最小的Linux系统—ttylinux体验
    im-switch -s ibus错误:Error: no configuration file "ibus" exists.
    Ruby环境搭建
    emulator: ERROR: x86 emulation currently requires hardware acceleration!Please ensure Intel HAXM is properly installed and usable.CPU acceleration status: HAX kernel module is not installed!
    POJ 1007 DNA Sorting
    POJ 1002 487-3279
    Ubuntu Android adb调试无法识别设备 -- List of devices attached ???????????? no permissions
  • 原文地址:https://www.cnblogs.com/wang-jing/p/5022271.html
Copyright © 2011-2022 走看看