Docker Community Forums

Share and learn in the Docker community.

Benchmarking a docker container

docker
dockerhub

(Vp2405) #1

Hi,
I’m new to Docker and i have to run some benchmark tools within docker containers, for example sysbench, but I have some doubts.
For example, I must have to run sysbench in a (for example) ubuntu image, or can i create an image only with it and build it? In Docker Hub there are many images, but I had a look to the code hosted on github, and it seems that the general way is to do (for example)

FROM ubuntu:latest
RUN apt-get install sysbench

if I try to write a Dockerfile with only

RUN apt-get install sysbench

I get : Please provide a source image with from prior to run

Thank you for the help.


(David Maze) #2

What’s your actual goal with this? Since Docker shares so much with the underlying system, a lot of the things sysbench claims to test won’t be much different within Docker vs. without. It seems like an unusual choice for a first Docker project to me.

You can write a Dockerfile that starts FROM scratch and you will get an absolutely empty filesystem. If you do that, your RUN apt-get install ... command will fail because there’s not an apt-get binary in $PATH, or, for that matter, a /bin directory.

If you statically compiled sysbench outside of Docker, you could write a Dockerfile like

FROM scratch
COPY sysbench /
ENTRYPOINT ["/sysbench"]
CMD ["help"]

But, again, this is a sort of intermediate-to-advanced setup. (You will have an image that only contains the sysbench binary and not, say, a shell; so if it doesn’t work your debugging options will be a little limited, and I’d suggest getting much more comfortable with the Docker ecosystem before trying this.)

You’re not required to use an Ubuntu base. You could start from Debian if you wanted; Alpine is not unpopular; CentOS is out there. (This choice is completely independent of what distribution, or even OS, the host system is running.) Searching hub.docker.com for “sysbench” is also likely to find you something prebuilt you can reuse.


(Vp2405) #3

It’s a university project…

While waiting for answers I tried this:

  • created a Dockerfile:

    FROM ubuntu:latest
    ADD script.sh /

    RUN apt-get update
    RUN apt-get -y install sysbench

(in script.h there are some instructions for sysbench)
-created an image “docker_sysbench”
-run a container with that image with docker run -i -t docker_sysbench /bin/bash
-run ./script.sh

and it seems to work…
Is this a correct solution?

Thanks for the help.