W
W
woyepol9692019-12-26 10:46:35
Docker
woyepol969, 2019-12-26 10:46:35

Docker multi-stage builds not seeing each other?

Dockerfile:

FROM php:7.4-fpm-alpine

RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

FROM node:alpine

Then when you try through docker exec just to check if the installation is correct, it says that node (or php) was not found. That is, one image overlaps another, how to make them installed within the same OS? Or only through apt?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Eugene, 2019-12-26
@yellowmew

If memory serves, intermediate builds are needed to generate artifacts used in the following builds. For example, when you do not want to carry the entire builddep with you to the final container (you need already assembled software there) and produce / clean layers.
Which is better in your case - I can’t even say. I would study how containers close in components are assembled on dockerhub

G
Georg Gaal, 2020-02-02
@gecube

If you need to put two services into one image, then the solution, unfortunately, is to write your own dockerfile. Which in structure will look like FROM of one of the two images, and then you need to copy (of course, with your head) the instructions for building the second image into a common Dockerfile. Or, in general, inherit from the base image with the operating system and manually fill it with all the necessary components (php, node, etc)
In simple cases, a variant like this works

FROM jrottenberg/ffmpeg:4.1-alpine as ffmpeg
FROM python:3.7-alpine3.8
RUN apk add --no-cache --update \
libgcc \
libstdc++ \
ca-certificates \
libcrypto1.0 \
libssl1.0 \
libgomp \
expat \
git
COPY --from=ffmpeg /usr/local /usr/local
.... a lot of stuff ....
ENTRYPOINT ["python", "capture_data.py"]

But this is if the components do not need to be registered in the system in any way, but it is enough to find libraries and executable files in certain paths.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question