Reputation: 795
I'm trying to create my first dev environment based on docker.
My host is Windows 10 I need to create stack Ubuntu:14.04 + php in separate images.
Dockerfile for ubuntu: FROM ubuntu:14.04
Dockerfile for php: FROM php:5.6-fpm
Just that simple. W\o any additional parameters at that point.
docker-compose.yml:
version: '3.7'
services:
os:
build:
context: .
dockerfile: .docker/ubuntu/Dockerfile
container_name: ubuntu
tty: true
links:
- php
php:
build: ./.docker/php
container_name: php
Then docker-compose up --build
result is:
Building os
Step 1/2 : FROM ubuntu:14.04
---> 971bb384a50a
Step 2/2 : LABEL maintainer="Andrey Kryukov"
---> Using cache
---> 3d71726444ee
Successfully built 3d71726444ee
Successfully tagged nnrservice_os:latest
Building php
Step 1/2 : FROM php:5.6-fpm
---> 8d3dc6499e61
Step 2/2 : LABEL maintainer="Andrey Kryukov"
---> Using cache
---> b6fc0c83131b
Successfully built b6fc0c83131b
Successfully tagged nnrservice_php:latest
Starting ubuntu ... done
Starting php ... done
Attaching to ubuntu, php
php | [24-Aug-2018 05:14:01] NOTICE: fpm is running, pid 1
php | [24-Aug-2018 05:14:01] NOTICE: ready to handle connections
And then docker-compose exec os /bin/sh
result is:
#
W\o any errors. So I expected that php will be available inside my console. But no!
# php -v
/bin/sh: 1: php: not found
#
What I am doing wrong? Or maybe I losing some important concept?
Upvotes: 1
Views: 815
Reputation: 21851
docker-compose exec os /bin/sh
You're connecting to the os
container and trying to execute php
, which is in the PHP
container. Obviously, that will not work because the os container has only the base utils, not the PHP libraries and PHP-FPM application which is in the php container, as evident by
php | [24-Aug-2018 05:14:01] NOTICE: fpm is running, pid 1
php | [24-Aug-2018 05:14:01] NOTICE: ready to handle connection
Why do you need an OS container and a PHP container? That defeats the purpose. The php container will have a base OS + required applications/libraries for PHP. You don't need two, if you goal is to just run PHP
Upvotes: 2