版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/jeffrey11223/article/details/82024930
先编辑DockerFile
基础镜像选的是 alpine
DockerFile内容如下 :
FROM alpine:latest
LABEL maintainer="me"
LABEL description="An environment with Boost C++ Libraries based on Alpine Linux."
ARG BOOST_VERSION=1.67.0
ARG BOOST_DIR=boost_1_67_0
ENV BOOST_VERSION ${BOOST_VERSION}
# Use bzip2-dev package for Boost IOStreams library support of zip and bzip2 formats
# Use openssl package for wget ssl_helper issue
RUN apk add --no-cache --virtual .build-dependencies \
openssl \
linux-headers \
build-base \
&& wget http://downloads.sourceforge.net/project/boost/boost/${BOOST_VERSION}/${BOOST_DIR}.tar.bz2 \
&& tar --bzip2 -xf ${BOOST_DIR}.tar.bz2 \
&& cd ${BOOST_DIR} \
&& ./bootstrap.sh \
&& ./b2 --without-python --prefix=/usr -j 4 link=shared runtime-link=shared install \
&& cd .. && rm -rf ${BOOST_DIR} ${BOOST_DIR}.tar.bz2 \
&& apk del .build-dependencies
RUN apk add build-base
RUN apk add cmake
RUN apk add git
CMD sh
build-base内部包含了gcc,这样以后如果更换机器,就不用花大把时间编译gcc了
build镜像:
docker build -t images/cpp_image ./dockfiles/
run镜像:
docker run -it --name mycontainer images/cpp_image