Skip to content

Instantly share code, notes, and snippets.

@jaimejim
Last active May 16, 2020 23:24
Show Gist options
  • Save jaimejim/bb71e689fafeaffe9b3bd5efaa6c81df to your computer and use it in GitHub Desktop.
Save jaimejim/bb71e689fafeaffe9b3bd5efaa6c81df to your computer and use it in GitHub Desktop.

Dockerized Mbed CLI

1. Dockerfile

Create this file named as Dockerfile

FROM debian:9-slim

RUN dpkg --add-architecture i386 \
  && DEBIAN_FRONTEND=noninteractive apt-get update -y -q \
  && DEBIAN_FRONTEND=noninteractive apt-get upgrade -y -q \
  && DEBIAN_FRONTEND=noninteractive apt-get install -y -q \
    python python-pip \
    libc6:i386 libncurses5:i386 libstdc++6:i386 \
    binutils-arm-none-eabi gcc-arm-none-eabi crossbuild-essential-armhf build-essential git mercurial \
  && pip install mbed-cli

ENV MBED_GCC_ARM_PATH /usr/bin

WORKDIR /mbed

# force mbed cli into installing missing python libs and toolchain
RUN cd /tmp && mbed new tmp0 && cd tmp0 && mbed compile >/dev/null 2>&1; cd .. && rm -r /tmp/tmp0 ; \
mbed config --global toolchain gcc_arm

# install vim and other useful tools
RUN apt-get update && apt-get install -y apt-utils && apt-get install -y vim

# Download blinky
cd ~/mbed && mbed import mbed-os-example-blinky

ENTRYPOINT [ "/usr/local/bin/mbed" ]

2. Build

docker build -t jaim/mbed-cli .

3. RUN

docker run -it --entrypoint=/bin/bash jaim/mbed-cli

4. Compile Blinky

Go to downloaded example directory

cd /mbed/mbed-os-example-blinky

Compile blinky example for K64F

mbed compile -m K64F -t GCC_ARM

Useful commands

Start a container : docker start 1a14d5296ce6

Execute an existing container : docker exec -ti 1a14d5296ce6 bash

List running containers (-a for all) : docker ps -a

List images : docker images

Stop all containers : docker stop $(docker ps -a -q)

Delete all containers : docker rm $(docker ps -a -q)

Delete all images : docker rmi $(docker images -q)

Docker Hub

Login : docker login

Pull image: docker pull jaim/mbed-cli or docker pull f50f9524513f

Commit : docker commit 9a951500de1d jaim/mbed-cli:latest

Tag : docker tag b3e70d12ce73 jaim/mbed-cli:latest

Push : docker push jaim/mbed-cli:latest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment