• 安恒赛题出题模板记录


    最近给安恒投稿题目,这篇文章用于记录 Dockerfile 内容。所有镜像基于 Ubuntu 官方镜像

    python3 + Django 2.2.11

    FROM ubuntu:16.04
    
    RUN sed -i 's/archive.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list && 
    	sed -i 's/security.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list && 
    	apt update -y && apt upgrade -y && apt install -y python3 && apt install -y python3-pip && mkdir /usr/src/app/ &&
    	mkdir ~/.pip/ && touch ~/.pip/pip.conf &&
    	echo '[global]' > ~/.pip/pip.conf && sed -i '1aindex-url = https://mirrors.aliyun.com/pypi/simple/
    
    [install]
    trusted-host=mirrors.aliyun.com' ~/.pip/pip.conf
    
    WORKDIR /usr/src/app
    COPY requirements.txt ./
    COPY ./challenge ./
    RUN pip3 install -r requirements.txt && python3 manage.py makemigrations && python3 manage.py migrate
    EXPOSE 80
    CMD ["python3", "manage.py", "runserver", "0.0.0.0:80"]
    

    PHP7 + apache2

    FROM ubuntu:16.04
    
    RUN sed -i 's/archive.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list && 
            sed -i 's/security.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list && 
            apt update -y && apt upgrade -y && apt install -y apache2 && 
            sed -i "1i ServerName localhost:80" /etc/apache2/apache2.conf && 
            apt install -y php && apt install -y libapache2-mod-php && 
            rm -rf /var/www/html/index.html
    
    RUN echo "flag{*******}" > /flag
    
    ADD www /var/www/html/
    
    RUN chmod 777 /var/www/html/session/ && 
    	service apache2 restart
    
    EXPOSE 80
    	
    CMD ["/usr/sbin/apache2ctl","-D","FOREGROUND"]
    

    docker 命令

    根据镜像生成容器

    docker run -itd --name ubuntu-test ubuntu:16.04

    进入容器

    docker exec -it 09cc51fd0baf /bin/bash

    停止容器

    docker stop f6848d0e59ac

    删除容器

    docker container rm f6848d0e59ac

    删除镜像

    docker rmi f6848d0e59ac

    根据 Dockerfile 构建镜像

    docker build -t test:v1 .

    根据构建的镜像运行容器

    docker run --name test2 -it -d -p 20003:80 test:v1

    导出镜像

    docker save -o hackus.tar test:v10

  • 相关阅读:
    动态代理,反射的用途及实现
    谈一谈web.xml中的context-param和init-param
    后端程序员需要了解的前端知识(持续更新中)
    angularJS要点记录,$location,$http等等
    HTTP1.0和HTTP2.0的区别,以及HTTP和HTTPS的区别
    浅谈Fork/Join框架
    ConcurrentHashMap 的工作原理及源码分析,如何统计所有的元素个数
    HTTP协议常见的状态码
    图解HTTP,状态码,TCP、UDP等网络协议相关总结(持续更新)
    jmeter(五)JDBC Request
  • 原文地址:https://www.cnblogs.com/peri0d/p/12851135.html
Copyright © 2020-2023  润新知