docker

术语

镜像:系统配置清单,用来创造容器,相当于菜谱
容器:是镜像的实现,相当于照着菜谱做菜。

docker 镜像源

  1. 改json 新版的 Docker 使用 /etc/docker/daemon.json(Linux) 或者%programdata%\docker\config\daemon.json(Windows) 来配置 Daemon。
    请在该配置文件中加入(没有该文件的话,请先建一个):
ustc   "registry-mirrors": ["https://docker.mirrors.ustc.edu.cn"]
163     http://hub-mirror.c.163.com
中国官方    https://registry.docker-cn.com
  1. -registry-mirror参数
docker run hello-world --registry-mirror=https://docker.mirrors.ustc.edu.cn
  1. 修改/etc/default/docker
mirror=https://docker.mirrors.ustc.edu.cn"

Docker registry 拉取镜像

alpine 是镜像名称,是一个轻量级的linux 发行版

docker image pull alpine

下面一条命令显示本地的镜像

docker image ls

运行container

docker container run 镜像名 运行的命令

-it 可以保持container 不退出,进行交互。

 docker container run -it alpine /bin/sh

列出正在运行的container,如果加上-a则是全部的(包括已经停止的)container

docker container ls
docker container ls -a

新建自定义docker镜像

docker build -t tutorial -f ./dockerfile.txt  ./

从镜像创建和运行容器

docker run -it --name container1 --net=host -v E:/docker/:/ds tutorial

简单镜像文件

# reference: https://hub.docker.com/_/ubuntu/
FROM ubuntu:16.04

# Adds metadata to the image as a key value pair example LABEL version="1.0"
LABEL maintainer="Hamel Husain <www.github.com/hamelsmu>"

##Set environment variables
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8

RUN apt-get update --fix-missing && apt-get install -y wget bzip2 ca-certificates \
    build-essential \
    byobu \
    curl \
    git-core \
    htop \
    pkg-config \
    python3-dev \
    python3-pip \
    python-setuptools \
    python-virtualenv \
    unzip \
    && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

RUN echo 'export PATH=/opt/conda/bin:$PATH' > /etc/profile.d/conda.sh && \
    wget --quiet https://repo.continuum.io/archive/Anaconda3-5.0.0.1-Linux-x86_64.sh -O ~/anaconda.sh && \
    /bin/bash ~/anaconda.sh -b -p /opt/conda && \
    rm ~/anaconda.sh

ENV PATH /opt/conda/bin:$PATH

RUN pip3 --no-cache-dir install --upgrade \
        altair \
        sklearn-pandas

# Open Ports for Jupyter
EXPOSE 7745

#Setup File System
RUN mkdir ds
ENV HOME=/ds
ENV SHELL=/bin/bash
VOLUME /ds
WORKDIR /ds
ADD run_jupyter.sh /ds/run_jupyter.sh
RUN chmod +x /ds/run_jupyter.sh

# Run the shell
CMD  ["./run_jupyter.sh"]

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 转载自 http://blog.opskumu.com/docker.html 一、Docker 简介 Docke...
    极客圈阅读 10,544评论 0 120
  • Docker — 云时代的程序分发方式 要说最近一年云计算业界有什么大事件?Google Compute Engi...
    ahohoho阅读 15,636评论 15 147
  • 一 、什么是 Docker Docker 最初是 dotCloud 公司创始人 Solomon Hykes 在法国...
    Blazzer阅读 3,177评论 0 13
  • 一、Docker 简介 Docker 两个主要部件:Docker: 开源的容器虚拟化平台Docker Hub: 用...
    R_X阅读 4,409评论 0 27
  • 他在密闭空间里用石子刻下行行字。。。。 他狰狞着看着从身上溜过的蟑螂,那蟑螂注意到一丝紧张的气息,顿顿了触角,他一...
    关馨仁阅读 252评论 0 0