docker-compose-build

Building Custom Docker Images using docker-compose

Summary

Building custom docker containers using docker-compose

  1. Create a docker-compose.yml using build: .
  2. In the same folder place a Dockerfile for single or two stage build
  3. docker-compose up will build the image and then run it

docker-compose.yml

# docker-compose.yml to build and run vlmcsd locally 
version: "2.4"

services:
  vlmcsd:
    container_name: vlmcsd.localhost
    build: .
    restart: always

    mem_limit: 8M

    ports:
      - "1688:1688"

Dockerfile

FROM alpine:latest as builder
WORKDIR /root
RUN apk add --no-cache git make build-base && \
    git clone --branch master --single-branch https://github.com/Wind4/vlmcsd.git && \
    cd vlmcsd/ && \
    make

FROM alpine:latest
WORKDIR /root/
COPY --from=builder /root/vlmcsd/bin/vlmcsd /usr/bin/vlmcsd
EXPOSE 1688/tcp
CMD [ "/usr/bin/vlmcsd", "-D", "-d" ]