How do I run a docker image in Circle CI 2.0?


#1

I have built a docker image with Centos7 as base image.
I pushed my image to a public repository in hub.docker.com.
How do I run this image in circleCI 2.0?

I have a .circleci/config.yml that has:

jobs:
  centos_py2_miniconda:
    docker:
      - image: muryanto1/mycentos7:mycentos7withgit
    environment:
      WORKDIR: "workspace"
      PYTHON_VERSION: 'py2'
    steps:
      - run: date '+%Y-%m-%d' 
      - run: uname -a
      - run: cat /proc/version

When I ran my workflow, I see ‘cat /proc/version’ is showing Ubuntu instead of CentOS.
Can someone point me what I should do to run commands/steps in my docker image?
Note that I will not be running any docker command in my steps.
Thank you!


#2

(When presenting YAML here, please use code formatting and not quote formatting, so that your space indentation is preserved. Please fix this now by editing your question when you next sign in, thanks).

Formatting aside, what you have looks OK to me. In your job steps, does the image appear to pull? If the job completes, then it worked, and you’re using your Centos image.

I don’t know how much you can rely on stuff in /proc/ however - note that containerisation is very lightweight, and there are some things in containers that in fact belong to the host. The question you need to be asking yourself is: does your container do what you need Centos for?


#3

This is my circle CI build:
https://circleci.com/gh/CDAT/cdat/2891
I added a ‘run: git’
From “Spin up Environment”, it looks like my right image got downloaded.
but you can see that ‘uname -a’ is running ubuntu, and running ‘git -h’ shows “command not found”.

When I ran my docker image locally, I am seeing:
[root@26514b73e4f9 /]# uname -a
Linux 26514b73e4f9 3.10.0-862.3.2.el7.x86_64 #1 SMP Tue May 15 18:22:15 EDT 2018 x86_64 x86_64 x86_64 GNU/Linux
[root@26514b73e4f9 /]# git
usage: git [–version] [–help] [-c name=value]
[–exec-path[=]] [–html-path] [–man-path] [–info-path]
[-p|–paginate|–no-pager] [–no-replace-objects] [–bare]
[–git-dir=] [–work-tree=] [–namespace=]
[]

What should I do to run steps in my docker image?


#4

I got it working. My .circleci/config.yml is okay as you pointed out. I had a misunderstanding on how to create a docker image. I recreated my docker image of CentOS with git installed in it, and I can see my circleCI step can access the git in my image. Thank you so much!!


#5

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.