Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Going inside docker container in build step

I am trying to use bitbucket pipeline as follows

 

image: ubuntu:16.04

pipelines:
default:
- step:
script:
- apt-get update
- apt-get install -y curl
- curl -L https://github.com/docker/compose/releases/download/1.18.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
- chmod +x /usr/local/bin/docker-compose
- docker network create docker_default
- docker-compose -f docker/production.yml up -d --build
- docker exec -i -d frontend_php bash
- cd /var/www
- composer install
services:
- docker

 

What i wanted to do is do docker-exec  and then do rest of my steps including composer install and unit testing inside the container.

 

Somehow I receive the following error.

 

bash: cd: /var/www: No such file or directory

 

I am not sure if this is trying to run the cd command inside my frontend_php container or the build container.

 

I have mounted the code to /var/www in my production.yml file as follows 

 

version: '2'
services:
frontend_php:
container_name: frontend_php
build: ./php-fpm
working_dir: /var/www
networks:
- docker_default
volumes:
- ../:/var/www
frontend_nginx:
container_name: frontend_nginx
build: ./nginx
working_dir: /var/www
networks:
- docker_default
volumes_from:
- frontend_php
ports:
- 8080:80

networks:
docker_default:
external: true

2 answers

If you want my advice install any php library using composer and then run `docker-compose up` as any command you run after `docker exec -i -d frontend_php bash` is executed within pipeline host  not within your docker image.

you can check https://hub.docker.com/r/zaherg/php-7.2-xdebug-alpine/ which will provide you with a ready to run php image that has composer already installed, so your pipeline will be something like:

 

image: zaherg/php-7.2-xdebug-alpine:latest

pipelines:
default:
- step:
script:
- composer install

- curl -L https://github.com/docker/compose/releases/download/1.18.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
- chmod +x /usr/local/bin/docker-compose
- docker network create docker_default
- docker-compose -f docker/production.yml up -d --build
services:
- docker
0 votes

did you ever figure this out. ? 

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket

Powering DevOps with Bitbucket Server & Data Center

Hi everyone, The Cloud team recently announced 12 new DevOps features that help developers ship better code, faster   ! While we’re all excited about the new improvements to Bitbucket ...

1,849 views 0 7
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you