Build Docker Image from Dockerfile w/o Registry

docker

#1

Is it possible to just build the docker image from a local Dockerfile and not pull the image from a registry?

Here’s how I’m doing this in 1.0:

machine:
    services:
      - docker

dependencies:
  override:
    - docker build -t my_image .

Basically, what is the 2.0 equivalent?


#2

Basically the same. Use the machine executor.

https://circleci.com/docs/2.0/executor-types/#machine-executor


#3

How does Postgres work in this case? Is it automatically available like in 1.0 or do I need to specify it in the docker section?


#4

You’d need to pull in a Postgres container. We originally had it installed but it conflicted with docker-compose configs.


#5

Gotcha, and so in my current config, I have:

test:
  override:
    - >-
      docker run --network host
      -e FLASK_CONFIG=$FLASK_CONFIG
      --entrypoint python darwin:latest -m unittest discover -v -s test

The --network host doesn’t work in 1.0, but I’m hoping 2.0 will allow the docker run command to access postgres on the host.

Is that the case? Basically, how do I ensure my tests inside of the docker run command have access to the PG image?


#6

Looks right to me. Defining the network should be sufficient.


#7

Great - I’ll give it a go and see if I can get it working.


#8

Sorry but I’m new here, I still dont know how to do that

machine:
services:
  - docker

dependencies:
  override:
- docker build -t my_image .

on the new circieci 2.0 version. Could you let me an example please?

Thanks!


#9

Any shell commands you wish to run need to go in run steps. Here is an example.


#10

Oh I got it! thanks a lot @halfer! :smiley:


#11