0

Recently I was able to run my app with ibmcom/mq:9.1.3.0-r3 and following Dockerfile definition:

FROM ibmcom/mq:9.1.3.0-r3
ENV LICENSE accept
ENV MQ_QMGR_NAME QM_MY_APP
USER root
RUN usermod -a -G mqm admin 
RUN usermod -a -G mqm root 
RUN useradd -g mqm my_user_id
ADD QueueManager /etc/mqm/myapp.mqsc
USER mqm

But now ibmcom/mq:9.1.3.0-r3 is not available on Dockerhub. When I pull and run other available docker versions (like 9.2.0.0-r1 and up) it throws following error because of commands in Dockerfile:

useradd: group 'mqm' does not exist

I read the MQ Custom Docker Image - MQM Group Not Found, where the user "chughts" suggests to "use htpasswd with bcrypt to create the users."

Does anyone knows, how to use htpasswd to create the users in mq? Thanks a lot for Your support in advance!

EDIT: I need to create an user via htpasswr for debug and local tests only. In production envirounment the qm's default user settings is used.

neznayka
  • 1
  • 1

1 Answers1

0

The developer configuration of the container, does it using go modules.

https://github.com/ibm-messaging/mq-container/blob/master/cmd/runmqdevserver/main.go

It looks up the password from the environment setting, then runs

    appPassword, set := os.LookupEnv("MQ_APP_PASSWORD")
    if set {
        err = htpasswd.SetPassword("app", appPassword, false)
        if err != nil {
            logTerminationf("Error setting app password: %v", err)
            return err
        }
    }

The package htpasswd is in https://github.com/ibm-messaging/mq-container/blob/master/internal/htpasswd/htpasswd.go

which has a SetPassword function

// SetPassword sets encrypted password for the user into htpasswd file
func SetPassword(user string, password string, isTest bool) error {
   ...

which right at the end saves the encrypted password

    // Update the password file
    return passwords.updateHtPasswordFile(isTest)

which does

func (htpfile mapHtPasswd) updateHtPasswordFile(isTest bool) error {

    file := "/etc/mqm/mq.htpasswd"
    if isTest {
        file = "my.htpasswd"
    }
    return ioutil.WriteFile(file, htpfile.GetBytes(), 0660)
}

This go code gets executed when building the developer image. I need to verify if this code stays on the machine, but you should be able to crib from the repo, to create your own go code that invokes htpasswd.SetPassword, passing in your own user / password combinations.

Update: Looks like the go runtime as well as the code is removed from the image, so you have options, but the easiest might be to clone the repo, and build your own custom developer image version, with the extra users.

Instructions for building a custom developer image can be found here - https://github.com/ibm-messaging/mq-container/blob/master/docs/building.md

chughts
  • 4,210
  • 2
  • 14
  • 27
  • Hi @chughts, thanks a lot for Your reply. I will check asap and let You know about my result. Best regards! – neznayka Oct 06 '21 at 14:17